Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jan 2009 00:14:34 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r187659 - in user/sam/wifi/sys/dev/ath: . ath_hal ath_hal/ar5210 ath_hal/ar5211 ath_hal/ar5212 ath_hal/ar5416
Message-ID:  <200901240014.n0O0EYsh058009@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sam
Date: Sat Jan 24 00:14:34 2009
New Revision: 187659
URL: http://svn.freebsd.org/changeset/base/187659

Log:
  Fix GSM, 1/2 and 1/4 width channels:
  o 1/2 and 1/4 width channels are included in IEEE80211_CHAN_ALL and
    IEEE80211_CHAN_ALLTURBO which caused them to be visible in various
    switch statements; deal with this for now by defining
    IEEE80211_CHAN_ALLFULL and IEEE80211_CHAN_ALLTURBOFULL that have
    these masked out (long term we should remove all direct usage of ic_flags)
  o GSM channels were broken by removal of the frequency mapping; fix
    this by making the frequency in HAL_CHANNEL_PRIVATE hold the mapped
    frequency and deal with the translation when setting up the private
    channel array; this has the benefit of making this transparent to
    the driver
  o add ath_hal_gethwchannel api to map an 802.11 channel to the
    ``hw frequency''; this just find the private channel and returns the
    (possibly mapped) frequency
  o use ath_hal_gethwchannel everywhere (even in 5210, 5211, and 5416
    parts that don't (yet) support 1/2 and 1/4 width channels); beware
    that we cannot use this in the code that returns the power limits
    as it is used when constructing the initial channel list and those
    are never mapped (and at that point the private channel map is not
    yet setup)
  
  May want to promote IEEE80211_CHAN_ALLFULL and IEEE80211_CHAN_ALLTURBOFULL
  to _ieee80211.h.

Modified:
  user/sam/wifi/sys/dev/ath/   (props changed)
  user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h
  user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2316.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2317.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2413.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2425.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5112.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5413.c
  user/sam/wifi/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
  user/sam/wifi/sys/dev/ath/if_ath.c

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h	Sat Jan 24 00:14:34 2009	(r187659)
@@ -125,7 +125,7 @@ struct ath_hal_rf *ath_hal_rfprobe(struc
  * using ic_devdata in the ieee80211_channel.
  */
 typedef struct {
-	uint16_t	channel;	/* XXX remove */
+	uint16_t	channel;	/* h/w frequency, NB: may be mapped */
 	uint8_t		privFlags;
 #define	CHANNEL_IQVALID		0x01	/* IQ calibration valid */
 #define	CHANNEL_ANI_INIT	0x02	/* ANI state initialized */
@@ -141,6 +141,13 @@ typedef struct {
 /* channel requires noise floor check */
 #define	CHANNEL_NFCREQUIRED	IEEE80211_CHAN_PRIV0
 
+/* all full-width channels */
+#define	IEEE80211_CHAN_ALLFULL \
+	(IEEE80211_CHAN_ALL - (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
+#define	IEEE80211_CHAN_ALLTURBOFULL \
+	(IEEE80211_CHAN_ALLTURBO - \
+	 (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
+
 typedef struct {
 	uint32_t	halChanSpreadSupport 		: 1,
 			halSleepAfterBeaconBroken	: 1,
@@ -535,7 +542,7 @@ ath_hal_checkchannel(struct ath_hal *ah,
 
 	HALASSERT(c->ic_devdata < AH_PRIVATE(ah)->ah_nchan);
 	cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata];
-	HALASSERT(c->ic_freq == cc->channel);
+	HALASSERT(c->ic_freq == cc->channel || IEEE80211_IS_CHAN_GSM(c));
 	return cc;
 }
 #else
@@ -545,6 +552,17 @@ HAL_CHANNEL_INTERNAL *ath_hal_checkchann
 #endif /* AH_DEBUG */
 
 /*
+ * Return the h/w frequency for a channel.  This may be
+ * different from ic_freq if this is a GSM device that
+ * takes 2.4GHz frequencies and down-converts them.
+ */
+static OS_INLINE uint16_t
+ath_hal_gethwchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
+{
+	return ath_hal_checkchannel(ah, c)->channel;
+}
+
+/*
  * Convert between microseconds and core system clocks.
  */
 extern	u_int ath_hal_mac_clks(struct ath_hal *ah, u_int usecs);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -2175,6 +2175,26 @@ ath_hal_getchannels(struct ath_hal *ah,
 }
 
 /*
+ * Handle frequency mapping from 900Mhz range to 2.4GHz range
+ * for GSM radios.  This is done when we need the h/w frequency
+ * and the channel is marked IEEE80211_CHAN_GSM.
+ */
+static int
+ath_hal_mapgsm(int sku, int freq)
+{
+	if (sku == SKU_XR9)
+		return 1520 + freq;
+	if (sku == SKU_GZ901)
+		return 1544 + freq;
+	if (sku == SKU_SR9)
+		return 3344 - freq;
+	HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
+	    "%s: cannot map freq %u unknown gsm sku %u\n",
+	    __func__, freq, sku);
+	return freq;
+}
+
+/*
  * Setup the internal/private channel state given a table of
  * net80211 channels.  We collapse entries for the same frequency
  * and record the frequency for doing noise floor processing
@@ -2182,16 +2202,17 @@ ath_hal_getchannels(struct ath_hal *ah,
  */
 static HAL_BOOL
 assignPrivateChannels(struct ath_hal *ah,
-	struct ieee80211_channel chans[], int nchans)
+	struct ieee80211_channel chans[], int nchans, int sku)
 {
 	HAL_CHANNEL_INTERNAL *ic;
-	int i, j, next;
+	int i, j, next, freq;
 
 	next = 0;
 	for (i = 0; i < nchans; i++) {
+		struct ieee80211_channel *c = &chans[i];
 		for (j = i-1; j >= 0; j--)
-			if (chans[j].ic_freq == chans[i].ic_freq) {
-				chans[i].ic_devdata = chans[j].ic_devdata;
+			if (chans[j].ic_freq == c->ic_freq) {
+				c->ic_devdata = chans[j].ic_devdata;
 				break;
 			}
 		if (j < 0) {
@@ -2202,6 +2223,19 @@ assignPrivateChannels(struct ath_hal *ah
 				    __func__, N(AH_PRIVATE(ah)->ah_channels));
 				return AH_FALSE;
 			}
+			/*
+			 * Handle frequency mapping for 900MHz devices.
+			 * The hardware uses 2.4GHz frequencies that are
+			 * down-converted.  The 802.11 layer uses the
+			 * true frequencies.
+			 */
+			freq = IEEE80211_IS_CHAN_GSM(c) ?
+			    ath_hal_mapgsm(sku, c->ic_freq) : c->ic_freq;
+
+			HALDEBUG(ah, HAL_DEBUG_REGDOMAIN,
+			    "%s: private[%3u] %u/0x%x -> channel %u\n",
+			    __func__, next, c->ic_freq, c->ic_flags, freq);
+
 			ic = &AH_PRIVATE(ah)->ah_channels[next];
 			/*
 			 * NB: This clears privFlags which means ancillary
@@ -2209,8 +2243,8 @@ assignPrivateChannels(struct ath_hal *ah
 			 *     restarted and re-setup any per-channel state.
 			 */
 			OS_MEMZERO(ic, sizeof(*ic));
-			ic->channel = chans[i].ic_freq;
-			chans[i].ic_devdata = next;
+			ic->channel = freq;
+			c->ic_devdata = next;
 			next++;
 		}
 	}
@@ -2235,7 +2269,8 @@ ath_hal_init_channels(struct ath_hal *ah
 
 	status = getchannels(ah, chans, maxchans, nchans, modeSelect,
 	    cc, regDmn, enableExtendedChannels, &country, &rd2GHz, &rd5GHz);
-	if (status == HAL_OK && assignPrivateChannels(ah, chans, *nchans)) {
+	if (status == HAL_OK &&
+	    assignPrivateChannels(ah, chans, *nchans, AH_PRIVATE(ah)->ah_currentRD)) {
 		AH_PRIVATE(ah)->ah_rd2GHz = rd2GHz;
 		AH_PRIVATE(ah)->ah_rd5GHz = rd5GHz;
 
@@ -2253,14 +2288,33 @@ ath_hal_init_channels(struct ath_hal *ah
 HAL_STATUS
 ath_hal_set_channels(struct ath_hal *ah,
     struct ieee80211_channel chans[], int nchans,
-    HAL_CTRY_CODE cc, HAL_REG_DOMAIN regDmn)
+    HAL_CTRY_CODE cc, HAL_REG_DOMAIN rd)
 {
 	COUNTRY_CODE_TO_ENUM_RD *country;
 	REG_DOMAIN *rd5GHz, *rd2GHz;
 	HAL_STATUS status;
 
-	status = getregstate(ah, cc, regDmn, &country, &rd2GHz, &rd5GHz);
-	if (status == HAL_OK && assignPrivateChannels(ah, chans, nchans)) {
+	switch (rd) {
+	case SKU_SR9:
+	case SKU_XR9:
+	case SKU_GZ901:
+		/*
+		 * Map 900MHz sku's.  The frequencies will be mapped
+		 * according to the sku to compensate for the down-converter.
+		 * We use the FCC for these sku's as the mapped channel
+		 * list is known compatible (will need to change if/when
+		 * vendors do different mapping in different locales).
+		 */
+		status = getregstate(ah, CTRY_DEFAULT, SKU_FCC,
+		    &country, &rd2GHz, &rd5GHz);
+		break;
+	default:
+		status = getregstate(ah, cc, rd,
+		    &country, &rd2GHz, &rd5GHz);
+		rd = AH_PRIVATE(ah)->ah_currentRD;
+		break;
+	}
+	if (status == HAL_OK && assignPrivateChannels(ah, chans, nchans, rd)) {
 		AH_PRIVATE(ah)->ah_rd2GHz = rd2GHz;
 		AH_PRIVATE(ah)->ah_rd5GHz = rd5GHz;
 
@@ -2283,7 +2337,7 @@ ath_hal_checkchannel(struct ath_hal *ah,
 	HAL_CHANNEL_INTERNAL *cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata];
 
 	if (c->ic_devdata < AH_PRIVATE(ah)->ah_nchan &&
-	    c->ic_freq == cc->channel)
+	    (c->ic_freq == cc->channel || IEEE80211_IS_CHAN_GSM(c)))
 		return cc;
 	if (c->ic_devdata >= AH_PRIVATE(ah)->ah_nchan) {
 		HALDEBUG(ah, HAL_DEBUG_ANY,
@@ -2294,8 +2348,8 @@ ath_hal_checkchannel(struct ath_hal *ah,
 		HALDEBUG(ah, HAL_DEBUG_ANY,
 		    "%s: no match for %u/0x%x devdata %u channel %u\n",
 		   __func__, c->ic_freq, c->ic_flags, c->ic_devdata,
-		   AH_PRIVATE(ah)->ah_channels[c->ic_devdata].channel);
-		HALASSERT(c->ic_freq == cc->channel);
+		   cc->channel);
+		HALASSERT(c->ic_freq == cc->channel || IEEE80211_IS_CHAN_GSM(c));
 	}
 	return AH_NULL;
 }

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -728,6 +728,7 @@ static HAL_BOOL
 setupPowerSettings(struct ath_hal *ah, const struct ieee80211_channel *chan,
 	uint8_t cp[17])
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	const HAL_EEPROM_v1 *ee = AH_PRIVATE(ah)->ah_eeprom;
 	uint8_t gainFRD, gainF36, gainF48, gainF54;
 	uint8_t dBmRD, dBm36, dBm48, dBm54, dontcare;
@@ -738,9 +739,9 @@ setupPowerSettings(struct ath_hal *ah, c
 	cp[15] = (ee->ee_biasCurrents >> 4) & 0x7;
 	cp[16] = ee->ee_biasCurrents & 0x7;
 
-	if (chan->ic_freq < 5170 || chan->ic_freq > 5320) {
+	if (freq < 5170 || freq > 5320) {
 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid channel %u\n",
-		    __func__, chan->ic_freq);
+		    __func__, freq);
 		return AH_FALSE;
 	}
 
@@ -760,7 +761,7 @@ setupPowerSettings(struct ath_hal *ah, c
 #endif
 		return AH_FALSE;
 	}
-	group = ((chan->ic_freq - 5170) / 10);
+	group = ((freq - 5170) / 10);
 
 	if (group > 11) {
 		/* Pull 5.29 into the 5.27 group */
@@ -916,10 +917,11 @@ ar5210SetTransmitPower(struct ath_hal *a
 static HAL_BOOL
 ar5210SetChannel(struct ath_hal *ah, struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t data;
 
 	/* Set the Channel */
-	data = ath_hal_reverseBits((chan->ic_freq - 5120)/10, 5);
+	data = ath_hal_reverseBits((freq - 5120)/10, 5);
 	data = (data << 1) | 0x41;
 	OS_REG_WRITE(ah, AR_PHY(0x27), data);
 	OS_REG_WRITE(ah, AR_PHY(0x30), 0);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -895,7 +895,7 @@ getNoiseFloorThresh(struct ath_hal *ah, 
 {
 	HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:
 		*nft = ee->ee_noiseFloorThresh[0];
 		break;
@@ -1033,6 +1033,7 @@ static HAL_BOOL
 ar5211SetRf6and7(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
 #define	N(a)	(sizeof (a) / sizeof (a[0]))
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	struct ath_hal_5211 *ahp = AH5211(ah);
 	uint16_t rfXpdGain, rfPloSel, rfPwdXpd;
@@ -1047,18 +1048,18 @@ ar5211SetRf6and7(struct ath_hal *ah, con
 	 *	 during the read.
 	 * For readability, this should be changed to an enum or #define
 	 */
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:
-		if (chan->ic_freq > 4000 && chan->ic_freq < 5260) {
+		if (freq > 4000 && freq < 5260) {
 			tempOB = ee->ee_ob1;
 			tempDB = ee->ee_db1;
-		} else if (chan->ic_freq >= 5260 && chan->ic_freq < 5500) {
+		} else if (freq >= 5260 && freq < 5500) {
 			tempOB = ee->ee_ob2;
 			tempDB = ee->ee_db2;
-		} else if (chan->ic_freq >= 5500 && chan->ic_freq < 5725) {
+		} else if (freq >= 5500 && freq < 5725) {
 			tempOB = ee->ee_ob3;
 			tempDB = ee->ee_db3;
-		} else if (chan->ic_freq >= 5725) {
+		} else if (freq >= 5725) {
 			tempOB = ee->ee_ob4;
 			tempDB = ee->ee_db4;
 		} else {
@@ -1145,7 +1146,7 @@ ar5211SetAntennaSwitchInternal(struct at
 	uint32_t antSwitchA, antSwitchB;
 	int ix;
 
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:		ix = 0; break;
 	case IEEE80211_CHAN_B:		ix = 1; break;
 	case IEEE80211_CHAN_PUREG:	ix = 2; break;
@@ -1205,7 +1206,7 @@ ar5211SetBoardValues(struct ath_hal *ah,
 	struct ath_hal_5211 *ahp = AH5211(ah);
 	int arrayMode, falseDectectBackoff;
 
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:
 		arrayMode = 0;
 		OS_REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
@@ -1274,7 +1275,8 @@ ar5211SetBoardValues(struct ath_hal *ah,
 		    IEEE80211_IS_CHAN_OFDM(chan))
 			falseDectectBackoff += CB22_FALSE_DETECT_BACKOFF;
 	} else {
-		uint32_t remainder = chan->ic_freq % 32;
+		uint16_t freq = ath_hal_gethwchannel(ah, chan);
+		uint32_t remainder = freq % 32;
 
 		if (remainder && (remainder < 10 || remainder > 22))
 			falseDectectBackoff += ee->ee_falseDetectBackoff[arrayMode];
@@ -1310,6 +1312,7 @@ ar5211SetTxPowerLimit(struct ath_hal *ah
 static HAL_BOOL
 ar5211SetTransmitPower(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	TRGT_POWER_INFO *pi;
 	RD_EDGES_POWER *rep;
@@ -1318,7 +1321,7 @@ ar5211SetTransmitPower(struct ath_hal *a
 	int i;
 
 	/* setup the pcdac struct to point to the correct info, based on mode */
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:
 		eepromPcdacs.numChannels = ee->ee_numChannels11a;
 		eepromPcdacs.pChannelList= ee->ee_channels11a;
@@ -1346,7 +1349,7 @@ ar5211SetTransmitPower(struct ath_hal *a
 		return AH_FALSE;
 	}
 
-	ar5211SetPowerTable(ah, &eepromPcdacs, chan->ic_freq);
+	ar5211SetPowerTable(ah, &eepromPcdacs, freq);
 
 	rep = AH_NULL;
 	/* Match CTL to EEPROM value */
@@ -1491,6 +1494,7 @@ ar5211SetRateTable(struct ath_hal *ah, R
 	TRGT_POWER_INFO *pPowerInfo, uint16_t numChannels,
 	const struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	struct ath_hal_5211 *ahp = AH5211(ah);
 	static uint16_t ratesArray[NUM_RATES];
@@ -1530,7 +1534,7 @@ ar5211SetRateTable(struct ath_hal *ah, R
 		}
 		numEdges = i;
 
-		ar5211GetLowerUpperValues(chan->ic_freq, tempChannelList,
+		ar5211GetLowerUpperValues(freq, tempChannelList,
 			numEdges, &lowerChannel, &upperChannel);
 		/* Get the index for this channel */
 		for (i = 0; i < numEdges; i++)
@@ -1539,7 +1543,7 @@ ar5211SetRateTable(struct ath_hal *ah, R
 		HALASSERT(i != numEdges);
 
 		if ((lowerChannel == upperChannel &&
-		     lowerChannel == chan->ic_freq) ||
+		     lowerChannel == freq) ||
 		    pRdEdgesPower[i].flag) {
 			twiceMaxEdgePower = pRdEdgesPower[i].twice_rdEdgePower;
 			HALASSERT(twiceMaxEdgePower > 0);
@@ -1550,7 +1554,7 @@ ar5211SetRateTable(struct ath_hal *ah, R
 	for (i = 0; i < numChannels; i++)
 		tempChannelList[i] = pPowerInfo[i].testChannel;
 
-	ar5211GetLowerUpperValues(chan->ic_freq, tempChannelList,
+	ar5211GetLowerUpperValues(freq, tempChannelList,
 		numChannels, &lowerChannel, &upperChannel);
 
 	/* get the index for the channel */
@@ -1604,7 +1608,7 @@ ar5211SetRateTable(struct ath_hal *ah, R
 			}
 		}
 
-		twicePower = ar5211GetInterpolatedValue(chan->ic_freq,
+		twicePower = ar5211GetInterpolatedValue(freq,
 			lowerChannel, upperChannel, lowerPower, upperPower, 0);
 
 		/* Reduce power by band edge restrictions */

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2316.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2316.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2316.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -90,26 +90,27 @@ ar2316WriteRegs(struct ath_hal *ah, u_in
 static HAL_BOOL
 ar2316SetChannel(struct ath_hal *ah,  struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t channelSel  = 0;
 	uint32_t bModeSynth  = 0;
 	uint32_t aModeRefSel = 0;
 	uint32_t reg32       = 0;
 
-	OS_MARK(ah, AH_MARK_SETCHANNEL, chan->ic_freq);
+	OS_MARK(ah, AH_MARK_SETCHANNEL, freq);
 
-	if (chan->ic_freq < 4800) {
+	if (freq < 4800) {
 		uint32_t txctl;
 
-		if (((chan->ic_freq - 2192) % 5) == 0) {
-			channelSel = ((chan->ic_freq - 672) * 2 - 3040)/10;
+		if (((freq - 2192) % 5) == 0) {
+			channelSel = ((freq - 672) * 2 - 3040)/10;
 			bModeSynth = 0;
-		} else if (((chan->ic_freq - 2224) % 5) == 0) {
-			channelSel = ((chan->ic_freq - 704) * 2 - 3040) / 10;
+		} else if (((freq - 2224) % 5) == 0) {
+			channelSel = ((freq - 704) * 2 - 3040) / 10;
 			bModeSynth = 1;
 		} else {
 			HALDEBUG(ah, HAL_DEBUG_ANY,
 			    "%s: invalid channel %u MHz\n",
-			    __func__, chan->ic_freq);
+			    __func__, freq);
 			return AH_FALSE;
 		}
 
@@ -117,7 +118,7 @@ ar2316SetChannel(struct ath_hal *ah,  st
 		channelSel = ath_hal_reverseBits(channelSel, 8);
 
 		txctl = OS_REG_READ(ah, AR_PHY_CCK_TX_CTRL);
-		if (chan->ic_freq == 2484) {
+		if (freq == 2484) {
 			/* Enable channel spreading for channel 14 */
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
@@ -125,21 +126,21 @@ ar2316SetChannel(struct ath_hal *ah,  st
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
 		}
-	} else if ((chan->ic_freq % 20) == 0 && chan->ic_freq >= 5120) {
+	} else if ((freq % 20) == 0 && freq >= 5120) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 20 << 2), 8);
+			((freq - 4800) / 20 << 2), 8);
 		aModeRefSel = ath_hal_reverseBits(3, 2);
-	} else if ((chan->ic_freq % 10) == 0) {
+	} else if ((freq % 10) == 0) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 10 << 1), 8);
+			((freq - 4800) / 10 << 1), 8);
 		aModeRefSel = ath_hal_reverseBits(2, 2);
-	} else if ((chan->ic_freq % 5) == 0) {
+	} else if ((freq % 5) == 0) {
 		channelSel = ath_hal_reverseBits(
-			(chan->ic_freq - 4800) / 5, 8);
+			(freq - 4800) / 5, 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
 	} else {
 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid channel %u MHz\n",
-		    __func__, chan->ic_freq);
+		    __func__, freq);
 		return AH_FALSE;
 	}
 
@@ -175,8 +176,7 @@ ar2316SetRfRegs(struct ath_hal *ah, cons
 	struct ar2316State *priv = AR2316(ah);
 	int regWrites = 0;
 
-	HALDEBUG(ah, HAL_DEBUG_RFPARAM,
-	    "%s: chan 0x%x flag 0x%x modesIndex 0x%x\n",
+	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan %u/0x%x modesIndex %u\n",
 	    __func__, chan->ic_freq, chan->ic_flags, modesIndex);
 
 	HALASSERT(priv != AH_NULL);
@@ -644,6 +644,7 @@ ar2316GetChannelMaxMinPower(struct ath_h
 	const struct ieee80211_channel *chan,
 	int16_t *maxPow, int16_t *minPow)
 {
+	uint16_t freq = chan->ic_freq;		/* NB: never mapped */
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2316 *pRawDataset = AH_NULL;
 	const RAW_DATA_PER_CHANNEL_2316 *data=AH_NULL;
@@ -668,9 +669,9 @@ ar2316GetChannelMaxMinPower(struct ath_h
 	if (numChannels < 1)
 		return(AH_FALSE);
 
-	if ((chan->ic_freq < data[0].channelValue) ||
-	    (chan->ic_freq > data[numChannels-1].channelValue)) {
-		if (chan->ic_freq < data[0].channelValue) {
+	if ((freq < data[0].channelValue) ||
+	    (freq > data[numChannels-1].channelValue)) {
+		if (freq < data[0].channelValue) {
 			*maxPow = ar2316GetMaxPower(ah, &data[0]);
 			*minPow = ar2316GetMinPower(ah, &data[0]);
 			return(AH_TRUE);
@@ -682,19 +683,19 @@ ar2316GetChannelMaxMinPower(struct ath_h
 	}
 
 	/* Linearly interpolate the power value now */
-	for (last=0,i=0; (i<numChannels) && (chan->ic_freq > data[i].channelValue);
+	for (last=0,i=0; (i<numChannels) && (freq > data[i].channelValue);
 	     last = i++);
 	totalD = data[i].channelValue - data[last].channelValue;
 	if (totalD > 0) {
 		totalF = ar2316GetMaxPower(ah, &data[i]) - ar2316GetMaxPower(ah, &data[last]);
-		*maxPow = (int8_t) ((totalF*(chan->ic_freq-data[last].channelValue) + 
+		*maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) + 
 				     ar2316GetMaxPower(ah, &data[last])*totalD)/totalD);
 		totalMin = ar2316GetMinPower(ah, &data[i]) - ar2316GetMinPower(ah, &data[last]);
-		*minPow = (int8_t) ((totalMin*(chan->ic_freq-data[last].channelValue) +
+		*minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) +
 				     ar2316GetMinPower(ah, &data[last])*totalD)/totalD);
 		return(AH_TRUE);
 	} else {
-		if (chan->ic_freq == data[i].channelValue) {
+		if (freq == data[i].channelValue) {
 			*maxPow = ar2316GetMaxPower(ah, &data[i]);
 			*minPow = ar2316GetMinPower(ah, &data[i]);
 			return(AH_TRUE);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2317.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2317.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2317.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -81,20 +81,21 @@ ar2317WriteRegs(struct ath_hal *ah, u_in
 static HAL_BOOL
 ar2317SetChannel(struct ath_hal *ah,  const struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t channelSel  = 0;
 	uint32_t bModeSynth  = 0;
 	uint32_t aModeRefSel = 0;
 	uint32_t reg32       = 0;
 
-	OS_MARK(ah, AH_MARK_SETCHANNEL, chan->ic_freq);
+	OS_MARK(ah, AH_MARK_SETCHANNEL, freq);
 
-	if (chan->ic_freq < 4800) {
+	if (freq < 4800) {
 		uint32_t txctl;
-		channelSel = chan->ic_freq - 2272 ;
+		channelSel = freq - 2272 ;
 		channelSel = ath_hal_reverseBits(channelSel, 8);
 
 		txctl = OS_REG_READ(ah, AR_PHY_CCK_TX_CTRL);
-		if (chan->ic_freq == 2484) {
+		if (freq == 2484) {
 			/* Enable channel spreading for channel 14 */
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
@@ -102,21 +103,21 @@ ar2317SetChannel(struct ath_hal *ah,  co
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
 		}
-	} else if ((chan->ic_freq % 20) == 0 && chan->ic_freq >= 5120) {
+	} else if ((freq % 20) == 0 && freq >= 5120) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 20 << 2), 8);
+			((freq - 4800) / 20 << 2), 8);
 		aModeRefSel = ath_hal_reverseBits(3, 2);
-	} else if ((chan->ic_freq % 10) == 0) {
+	} else if ((freq % 10) == 0) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 10 << 1), 8);
+			((freq - 4800) / 10 << 1), 8);
 		aModeRefSel = ath_hal_reverseBits(2, 2);
-	} else if ((chan->ic_freq % 5) == 0) {
+	} else if ((freq % 5) == 0) {
 		channelSel = ath_hal_reverseBits(
-			(chan->ic_freq - 4800) / 5, 8);
+			(freq - 4800) / 5, 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
 	} else {
 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid channel %u MHz\n",
-		    __func__, chan->ic_freq);
+		    __func__, freq);
 		return AH_FALSE;
 	}
 
@@ -153,8 +154,7 @@ ar2317SetRfRegs(struct ath_hal *ah,
 	struct ar2317State *priv = AR2317(ah);
 	int regWrites = 0;
 
-	HALDEBUG(ah, HAL_DEBUG_RFPARAM,
-	    "%s: chan 0x%x flag 0x%x modesIndex 0x%x\n",
+	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan %u/0x%x modesIndex %u\n",
 	    __func__, chan->ic_freq, chan->ic_flags, modesIndex);
 
 	HALASSERT(priv);
@@ -624,6 +624,7 @@ ar2317GetChannelMaxMinPower(struct ath_h
 	const struct ieee80211_channel *chan,
 	int16_t *maxPow, int16_t *minPow)
 {
+	uint16_t freq = chan->ic_freq;		/* NB: never mapped */
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2317 *pRawDataset = AH_NULL;
 	const RAW_DATA_PER_CHANNEL_2317 *data=AH_NULL;
@@ -648,9 +649,9 @@ ar2317GetChannelMaxMinPower(struct ath_h
 	if (numChannels < 1)
 		return(AH_FALSE);
 
-	if ((chan->ic_freq < data[0].channelValue) ||
-	    (chan->ic_freq > data[numChannels-1].channelValue)) {
-		if (chan->ic_freq < data[0].channelValue) {
+	if ((freq < data[0].channelValue) ||
+	    (freq > data[numChannels-1].channelValue)) {
+		if (freq < data[0].channelValue) {
 			*maxPow = ar2317GetMaxPower(ah, &data[0]);
 			*minPow = ar2317GetMinPower(ah, &data[0]);
 			return(AH_TRUE);
@@ -662,19 +663,19 @@ ar2317GetChannelMaxMinPower(struct ath_h
 	}
 
 	/* Linearly interpolate the power value now */
-	for (last=0,i=0; (i<numChannels) && (chan->ic_freq > data[i].channelValue);
+	for (last=0,i=0; (i<numChannels) && (freq > data[i].channelValue);
 	     last = i++);
 	totalD = data[i].channelValue - data[last].channelValue;
 	if (totalD > 0) {
 		totalF = ar2317GetMaxPower(ah, &data[i]) - ar2317GetMaxPower(ah, &data[last]);
-		*maxPow = (int8_t) ((totalF*(chan->ic_freq-data[last].channelValue) + 
+		*maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) + 
 				     ar2317GetMaxPower(ah, &data[last])*totalD)/totalD);
 		totalMin = ar2317GetMinPower(ah, &data[i]) - ar2317GetMinPower(ah, &data[last]);
-		*minPow = (int8_t) ((totalMin*(chan->ic_freq-data[last].channelValue) +
+		*minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) +
 				     ar2317GetMinPower(ah, &data[last])*totalD)/totalD);
 		return(AH_TRUE);
 	} else {
-		if (chan->ic_freq == data[i].channelValue) {
+		if (freq == data[i].channelValue) {
 			*maxPow = ar2317GetMaxPower(ah, &data[i]);
 			*minPow = ar2317GetMinPower(ah, &data[i]);
 			return(AH_TRUE);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2413.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2413.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2413.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -77,27 +77,27 @@ ar2413WriteRegs(struct ath_hal *ah, u_in
 static HAL_BOOL
 ar2413SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t channelSel  = 0;
 	uint32_t bModeSynth  = 0;
 	uint32_t aModeRefSel = 0;
 	uint32_t reg32       = 0;
-	uint16_t freq;
 
-	OS_MARK(ah, AH_MARK_SETCHANNEL, chan->ic_freq);
+	OS_MARK(ah, AH_MARK_SETCHANNEL, freq);
 
-	if (chan->ic_freq < 4800) {
+	if (freq < 4800) {
 		uint32_t txctl;
 
-		if (((chan->ic_freq - 2192) % 5) == 0) {
-			channelSel = ((chan->ic_freq - 672) * 2 - 3040)/10;
+		if (((freq - 2192) % 5) == 0) {
+			channelSel = ((freq - 672) * 2 - 3040)/10;
 			bModeSynth = 0;
-		} else if (((chan->ic_freq - 2224) % 5) == 0) {
-			channelSel = ((chan->ic_freq - 704) * 2 - 3040) / 10;
+		} else if (((freq - 2224) % 5) == 0) {
+			channelSel = ((freq - 704) * 2 - 3040) / 10;
 			bModeSynth = 1;
 		} else {
 			HALDEBUG(ah, HAL_DEBUG_ANY,
 			    "%s: invalid channel %u MHz\n",
-			    __func__, chan->ic_freq);
+			    __func__, freq);
 			return AH_FALSE;
 		}
 
@@ -105,7 +105,7 @@ ar2413SetChannel(struct ath_hal *ah, con
 		channelSel = ath_hal_reverseBits(channelSel, 8);
 
 		txctl = OS_REG_READ(ah, AR_PHY_CCK_TX_CTRL);
-		if (chan->ic_freq == 2484) {
+		if (freq == 2484) {
 			/* Enable channel spreading for channel 14 */
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
@@ -113,26 +113,26 @@ ar2413SetChannel(struct ath_hal *ah, con
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
 		}
-	} else if (((chan->ic_freq % 5) == 2) && (chan->ic_freq <= 5435)) {
-		freq = chan->ic_freq - 2; /* Align to even 5MHz raster */
+	} else if (((freq % 5) == 2) && (freq <= 5435)) {
+		freq = freq - 2; /* Align to even 5MHz raster */
 		channelSel = ath_hal_reverseBits(
 			(uint32_t)(((freq - 4800)*10)/25 + 1), 8);
             	aModeRefSel = ath_hal_reverseBits(0, 2);
-	} else if ((chan->ic_freq % 20) == 0 && chan->ic_freq >= 5120) {
+	} else if ((freq % 20) == 0 && freq >= 5120) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 20 << 2), 8);
+			((freq - 4800) / 20 << 2), 8);
 		aModeRefSel = ath_hal_reverseBits(3, 2);
-	} else if ((chan->ic_freq % 10) == 0) {
+	} else if ((freq % 10) == 0) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 10 << 1), 8);
+			((freq - 4800) / 10 << 1), 8);
 		aModeRefSel = ath_hal_reverseBits(2, 2);
-	} else if ((chan->ic_freq % 5) == 0) {
+	} else if ((freq % 5) == 0) {
 		channelSel = ath_hal_reverseBits(
-			(chan->ic_freq - 4800) / 5, 8);
+			(freq - 4800) / 5, 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
 	} else {
 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid channel %u MHz\n",
-		    __func__, chan->ic_freq);
+		    __func__, freq);
 		return AH_FALSE;
 	}
 
@@ -170,8 +170,7 @@ ar2413SetRfRegs(struct ath_hal *ah,
 	struct ar2413State *priv = AR2413(ah);
 	int regWrites = 0;
 
-	HALDEBUG(ah, HAL_DEBUG_RFPARAM,
-	    "%s: chan 0x%x flag 0x%x modesIndex 0x%x\n",
+	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan %u/0x%x modesIndex %u\n",
 	    __func__, chan->ic_freq, chan->ic_flags, modesIndex);
 
 	HALASSERT(priv);
@@ -499,6 +498,7 @@ ar2413SetPowerTable(struct ath_hal *ah,
 	const struct ieee80211_channel *chan, 
 	uint16_t *rfXpdGain)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	struct ath_hal_5212 *ahp = AH5212(ah);
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2413 *pRawDataset = AH_NULL;
@@ -513,7 +513,7 @@ ar2413SetPowerTable(struct ath_hal *ah,
 #endif
 
 	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan 0x%x flag 0x%x\n",
-	    __func__, chan->ic_freq, chan->ic_flags);
+	    __func__, freq, chan->ic_flags);
 
 	if (IEEE80211_IS_CHAN_G(chan) || IEEE80211_IS_CHAN_108G(chan))
 		pRawDataset = &ee->ee_rawDataset2413[headerInfo11G];
@@ -528,7 +528,7 @@ ar2413SetPowerTable(struct ath_hal *ah,
 					  AR_PHY_TPCRG5_PD_GAIN_OVERLAP);
     
 	numPdGainsUsed = ar2413getGainBoundariesAndPdadcsForPowers(ah,
-		chan->ic_freq, pRawDataset, pdGainOverlap_t2,
+		freq, pRawDataset, pdGainOverlap_t2,
 		&minCalPower2413_t2,gainBoundaries, rfXpdGain, pdadcValues);
 	HALASSERT(1 <= numPdGainsUsed && numPdGainsUsed <= 3);
 
@@ -639,6 +639,7 @@ ar2413GetChannelMaxMinPower(struct ath_h
 	const struct ieee80211_channel *chan,
 	int16_t *maxPow, int16_t *minPow)
 {
+	uint16_t freq = chan->ic_freq;		/* NB: never mapped */
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2413 *pRawDataset = AH_NULL;
 	const RAW_DATA_PER_CHANNEL_2413 *data = AH_NULL;
@@ -663,9 +664,9 @@ ar2413GetChannelMaxMinPower(struct ath_h
 	if (numChannels < 1)
 		return(AH_FALSE);
 
-	if ((chan->ic_freq < data[0].channelValue) ||
-	    (chan->ic_freq > data[numChannels-1].channelValue)) {
-		if (chan->ic_freq < data[0].channelValue) {
+	if ((freq < data[0].channelValue) ||
+	    (freq > data[numChannels-1].channelValue)) {
+		if (freq < data[0].channelValue) {
 			*maxPow = ar2413GetMaxPower(ah, &data[0]);
 			*minPow = ar2413GetMinPower(ah, &data[0]);
 			return(AH_TRUE);
@@ -677,19 +678,19 @@ ar2413GetChannelMaxMinPower(struct ath_h
 	}
 
 	/* Linearly interpolate the power value now */
-	for (last=0,i=0; (i<numChannels) && (chan->ic_freq > data[i].channelValue);
+	for (last=0,i=0; (i<numChannels) && (freq > data[i].channelValue);
 	     last = i++);
 	totalD = data[i].channelValue - data[last].channelValue;
 	if (totalD > 0) {
 		totalF = ar2413GetMaxPower(ah, &data[i]) - ar2413GetMaxPower(ah, &data[last]);
-		*maxPow = (int8_t) ((totalF*(chan->ic_freq-data[last].channelValue) + 
+		*maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) + 
 				     ar2413GetMaxPower(ah, &data[last])*totalD)/totalD);
 		totalMin = ar2413GetMinPower(ah, &data[i]) - ar2413GetMinPower(ah, &data[last]);
-		*minPow = (int8_t) ((totalMin*(chan->ic_freq-data[last].channelValue) +
+		*minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) +
 				     ar2413GetMinPower(ah, &data[last])*totalD)/totalD);
 		return(AH_TRUE);
 	} else {
-		if (chan->ic_freq == data[i].channelValue) {
+		if (freq == data[i].channelValue) {
 			*maxPow = ar2413GetMaxPower(ah, &data[i]);
 			*minPow = ar2413GetMinPower(ah, &data[i]);
 			return(AH_TRUE);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2425.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2425.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar2425.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -84,22 +84,22 @@ ar2425WriteRegs(struct ath_hal *ah, u_in
 static HAL_BOOL
 ar2425SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t channelSel  = 0;
 	uint32_t bModeSynth  = 0;
 	uint32_t aModeRefSel = 0;
 	uint32_t reg32       = 0;
-	uint16_t freq;
 
-	OS_MARK(ah, AH_MARK_SETCHANNEL, chan->ic_freq);
+	OS_MARK(ah, AH_MARK_SETCHANNEL, freq);
 
-	if (chan->ic_freq < 4800) {
+	if (freq < 4800) {
 		uint32_t txctl;
 
-        channelSel = chan->ic_freq - 2272;
+        channelSel = freq - 2272;
         channelSel = ath_hal_reverseBits(channelSel, 8);
 
 		txctl = OS_REG_READ(ah, AR_PHY_CCK_TX_CTRL);
-        if (chan->ic_freq == 2484) {
+        if (freq == 2484) {
 			// Enable channel spreading for channel 14
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
@@ -108,26 +108,26 @@ ar2425SetChannel(struct ath_hal *ah, con
 				txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
 		}
 
-	} else if (((chan->ic_freq % 5) == 2) && (chan->ic_freq <= 5435)) {
-		freq = chan->ic_freq - 2; /* Align to even 5MHz raster */
+	} else if (((freq % 5) == 2) && (freq <= 5435)) {
+		freq = freq - 2; /* Align to even 5MHz raster */
 		channelSel = ath_hal_reverseBits(
 			(uint32_t)(((freq - 4800)*10)/25 + 1), 8);
             	aModeRefSel = ath_hal_reverseBits(0, 2);
-	} else if ((chan->ic_freq % 20) == 0 && chan->ic_freq >= 5120) {
+	} else if ((freq % 20) == 0 && freq >= 5120) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 20 << 2), 8);
+			((freq - 4800) / 20 << 2), 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
-	} else if ((chan->ic_freq % 10) == 0) {
+	} else if ((freq % 10) == 0) {
 		channelSel = ath_hal_reverseBits(
-			((chan->ic_freq - 4800) / 10 << 1), 8);
+			((freq - 4800) / 10 << 1), 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
-	} else if ((chan->ic_freq % 5) == 0) {
+	} else if ((freq % 5) == 0) {
 		channelSel = ath_hal_reverseBits(
-			(chan->ic_freq - 4800) / 5, 8);
+			(freq - 4800) / 5, 8);
 		aModeRefSel = ath_hal_reverseBits(1, 2);
 	} else {
 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid channel %u MHz\n",
-		    __func__, chan->ic_freq);
+		    __func__, freq);
 		return AH_FALSE;
 	}
 
@@ -164,8 +164,7 @@ ar2425SetRfRegs(struct ath_hal *ah,
 	uint16_t ob2GHz = 0, db2GHz = 0;
 	int regWrites = 0;
 
-	HALDEBUG(ah, HAL_DEBUG_RFPARAM,
-	    "==>%s:chan 0x%x flag 0x%x modesIndex 0x%x\n",
+	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan %u/0x%x modesIndex %u\n",
 	    __func__, chan->ic_freq, chan->ic_flags, modesIndex);
 
 	HALASSERT(priv);
@@ -499,6 +498,7 @@ ar2425SetPowerTable(struct ath_hal *ah,
 	const struct ieee80211_channel *chan, 
 	uint16_t *rfXpdGain)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	struct ath_hal_5212 *ahp = AH5212(ah);
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2413 *pRawDataset = AH_NULL;
@@ -509,7 +509,7 @@ ar2425SetPowerTable(struct ath_hal *ah,
 	uint32_t i, reg32, regoffset;
 
 	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s:chan 0x%x flag 0x%x\n",
-	    __func__, chan->ic_freq, chan->ic_flags);
+	    __func__, freq, chan->ic_flags);
 
 	if (IEEE80211_IS_CHAN_G(chan) || IEEE80211_IS_CHAN_108G(chan))
 		pRawDataset = &ee->ee_rawDataset2413[headerInfo11G];
@@ -523,7 +523,7 @@ ar2425SetPowerTable(struct ath_hal *ah,
 	pdGainOverlap_t2 = (uint16_t) SM(OS_REG_READ(ah, AR_PHY_TPCRG5),
 					  AR_PHY_TPCRG5_PD_GAIN_OVERLAP);
     
-	ar2425getGainBoundariesAndPdadcsForPowers(ah, chan->ic_freq,
+	ar2425getGainBoundariesAndPdadcsForPowers(ah, freq,
 		pRawDataset, pdGainOverlap_t2,&minCalPower2413_t2,gainBoundaries,
 		rfXpdGain, pdadcValues);
 
@@ -602,6 +602,7 @@ ar2425GetChannelMaxMinPower(struct ath_h
 	const struct ieee80211_channel *chan,
 	int16_t *maxPow, int16_t *minPow)
 {
+	uint16_t freq = chan->ic_freq;		/* NB: never mapped */
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	const RAW_DATA_STRUCT_2413 *pRawDataset = AH_NULL;
 	const RAW_DATA_PER_CHANNEL_2413 *data = AH_NULL;
@@ -626,9 +627,9 @@ ar2425GetChannelMaxMinPower(struct ath_h
 	if (numChannels < 1)
 		return(AH_FALSE);
 
-	if ((chan->ic_freq < data[0].channelValue) ||
-	    (chan->ic_freq > data[numChannels-1].channelValue)) {
-		if (chan->ic_freq < data[0].channelValue) {
+	if ((freq < data[0].channelValue) ||
+	    (freq > data[numChannels-1].channelValue)) {
+		if (freq < data[0].channelValue) {
 			*maxPow = ar2425GetMaxPower(ah, &data[0]);
 			*minPow = ar2425GetMinPower(ah, &data[0]);
 			return(AH_TRUE);
@@ -640,19 +641,19 @@ ar2425GetChannelMaxMinPower(struct ath_h
 	}
 
 	/* Linearly interpolate the power value now */
-	for (last=0,i=0; (i<numChannels) && (chan->ic_freq > data[i].channelValue);
+	for (last=0,i=0; (i<numChannels) && (freq > data[i].channelValue);
 	     last = i++);
 	totalD = data[i].channelValue - data[last].channelValue;
 	if (totalD > 0) {
 		totalF = ar2425GetMaxPower(ah, &data[i]) - ar2425GetMaxPower(ah, &data[last]);
-		*maxPow = (int8_t) ((totalF*(chan->ic_freq-data[last].channelValue) + 
+		*maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) + 
 				     ar2425GetMaxPower(ah, &data[last])*totalD)/totalD);
 		totalMin = ar2425GetMinPower(ah, &data[i]) - ar2425GetMinPower(ah, &data[last]);
-		*minPow = (int8_t) ((totalMin*(chan->ic_freq-data[last].channelValue) +
+		*minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) +
 				     ar2425GetMinPower(ah, &data[last])*totalD)/totalD);
 		return(AH_TRUE);
 	} else {
-		if (chan->ic_freq == data[i].channelValue) {
+		if (freq == data[i].channelValue) {
 			*maxPow = ar2425GetMaxPower(ah, &data[i]);
 			*minPow = ar2425GetMinPower(ah, &data[i]);
 			return(AH_TRUE);

Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c
==============================================================================
--- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c	Fri Jan 23 22:49:23 2009	(r187658)
+++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c	Sat Jan 24 00:14:34 2009	(r187659)
@@ -77,6 +77,7 @@ static HAL_BOOL
 ar5111SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
 {
 #define CI_2GHZ_INDEX_CORRECTION 19
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	uint32_t refClk, reg32, data2111;
 	int16_t chan5111, chanIEEE;
 
@@ -140,7 +141,7 @@ ar5111SetChannel(struct ath_hal *ah, con
 		{ 1, 0x46, 180 } 	/* 2732  26 */
 	};
 
-	OS_MARK(ah, AH_MARK_SETCHANNEL, chan->ic_freq);
+	OS_MARK(ah, AH_MARK_SETCHANNEL, freq);
 
 	chanIEEE = chan->ic_ieee;
 	if (IEEE80211_IS_CHAN_2GHZ(chan)) {
@@ -153,7 +154,7 @@ ar5111SetChannel(struct ath_hal *ah, con
 			 | (ci->refClkSel << 4);
 		chan5111 = ci->channel5111;
 		txctl = OS_REG_READ(ah, AR_PHY_CCK_TX_CTRL);
-		if (chan->ic_freq == 2484) {
+		if (freq == 2484) {
 			/* Enable channel spreading for channel 14 */
 			OS_REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
 				txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
@@ -217,6 +218,7 @@ static HAL_BOOL
 ar5111SetRfRegs(struct ath_hal *ah, const struct ieee80211_channel *chan,
 	uint16_t modesIndex, uint16_t *rfXpdGain)
 {
+	uint16_t freq = ath_hal_gethwchannel(ah, chan);
 	struct ath_hal_5212 *ahp = AH5212(ah);
 	const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom;
 	uint16_t rfXpdGainFixed, rfPloSel, rfPwdXpd, gainI;
@@ -224,19 +226,22 @@ ar5111SetRfRegs(struct ath_hal *ah, cons
 	uint32_t ob2GHz, db2GHz, rfReg[N(ar5212Bank6_5111)];
 	int i, regWrites = 0;
 
+	HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: chan %u/0x%x modesIndex %u\n",
+	    __func__, chan->ic_freq, chan->ic_flags, modesIndex);
+
 	/* Setup rf parameters */
-	switch (chan->ic_flags & IEEE80211_CHAN_ALL) {
+	switch (chan->ic_flags & IEEE80211_CHAN_ALLFULL) {
 	case IEEE80211_CHAN_A:
-		if (4000 < chan->ic_freq && chan->ic_freq < 5260) {
+		if (4000 < freq && freq < 5260) {
 			tempOB = ee->ee_ob1;
 			tempDB = ee->ee_db1;
-		} else if (5260 <= chan->ic_freq && chan->ic_freq < 5500) {
+		} else if (5260 <= freq && freq < 5500) {
 			tempOB = ee->ee_ob2;
 			tempDB = ee->ee_db2;
-		} else if (5500 <= chan->ic_freq && chan->ic_freq < 5725) {
+		} else if (5500 <= freq && freq < 5725) {
 			tempOB = ee->ee_ob3;
 			tempDB = ee->ee_db3;
-		} else if (chan->ic_freq >= 5725) {
+		} else if (freq >= 5725) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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