From d8f56a6f5b70c6d42d97990776d14e63a40ac397 Mon Sep 17 00:00:00 2001
From: Damien Bergamini <damien@cvs.openbsd.org>
Date: Sun, 1 Nov 2009 12:01:17 +0000
Subject: - fix rx chain mask in scan command - no Tx IQ calibration for 6000
 series - remove a comment about iwlwifi that is no longer true

---
 sys/dev/pci/if_iwn.c    | 19 +++++++++----------
 sys/dev/pci/if_iwnreg.h | 10 +++++-----
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 2a4b52c882c..2ae6e0ca4cd 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_iwn.c,v 1.73 2009/10/31 11:52:07 damien Exp $	*/
+/*	$OpenBSD: if_iwn.c,v 1.74 2009/11/01 12:01:16 damien Exp $	*/
 
 /*-
  * Copyright (c) 2007-2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -553,10 +553,6 @@ iwn_hal_attach(struct iwn_softc *sc, pci_product_id_t pid)
 		sc->sc_hal = &iwn4965_hal;
 		sc->limits = &iwn4965_sensitivity_limits;
 		sc->fwname = "iwn-4965";
-		/*
-		 * The 4965 is supposed to have 3 RX chains, but the
-		 * Intel driver only activates 2.
-		 */
 		sc->txchainmask = IWN_ANT_AB;
 		sc->rxchainmask = IWN_ANT_ABC;
 		break;
@@ -2037,7 +2033,8 @@ iwn5000_rx_calib_results(struct iwn_softc *sc, struct iwn_rx_desc *desc,
 		idx = 2;
 		break;
 	case IWN5000_PHY_CALIB_TX_IQ_PERD:
-		if (sc->hw_type != IWN_HW_REV_TYPE_5150)
+		if (sc->hw_type < IWN_HW_REV_TYPE_6000 &&
+		    sc->hw_type != IWN_HW_REV_TYPE_5150)
 			idx = 3;
 		break;
 	case IWN5000_PHY_CALIB_BASE_BAND:
@@ -4170,14 +4167,16 @@ iwn_scan(struct iwn_softc *sc, uint16_t flags)
 	hdr->quiet_threshold = htole16(1);	/* min # of packets */
 
 	/* Select antennas for scanning. */
-	rxchain = IWN_RXCHAIN_FORCE | IWN_RXCHAIN_VALID(IWN_ANT_ABC) |
-	    IWN_RXCHAIN_MIMO(IWN_ANT_ABC);
+	rxchain =
+	    IWN_RXCHAIN_VALID(sc->rxchainmask) |
+	    IWN_RXCHAIN_FORCE_MIMO_SEL(sc->rxchainmask) |
+	    IWN_RXCHAIN_DRIVER_FORCE;
 	if ((flags & IEEE80211_CHAN_5GHZ) &&
 	    sc->hw_type == IWN_HW_REV_TYPE_4965) {
 		/* Ant A must be avoided in 5GHz because of an HW bug. */
-		rxchain |= IWN_RXCHAIN_SEL(IWN_ANT_BC);
+		rxchain |= IWN_RXCHAIN_FORCE_SEL(IWN_ANT_BC);
 	} else	/* Use all available RX antennas. */
-		rxchain |= IWN_RXCHAIN_SEL(IWN_ANT_ABC);
+		rxchain |= IWN_RXCHAIN_FORCE_SEL(sc->rxchainmask);
 	hdr->rxchain = htole16(rxchain);
 	hdr->filter = htole32(IWN_FILTER_MULTICAST | IWN_FILTER_BEACON);
 
diff --git a/sys/dev/pci/if_iwnreg.h b/sys/dev/pci/if_iwnreg.h
index 5d7362ce445..c8c93660f12 100644
--- a/sys/dev/pci/if_iwnreg.h
+++ b/sys/dev/pci/if_iwnreg.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_iwnreg.h,v 1.31 2009/10/28 18:42:47 damien Exp $	*/
+/*	$OpenBSD: if_iwnreg.h,v 1.32 2009/11/01 12:01:16 damien Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008
@@ -461,10 +461,10 @@ struct iwn_rxon {
 
 	uint8_t		air;
 	uint16_t	rxchain;
-#define IWN_RXCHAIN_FORCE		(1 << 0)
-#define IWN_RXCHAIN_VALID(x)		((x) <<  1)
-#define IWN_RXCHAIN_SEL(x)		((x) <<  4)
-#define IWN_RXCHAIN_MIMO(x)		((x) <<  7)
+#define IWN_RXCHAIN_DRIVER_FORCE	(1 << 0)
+#define IWN_RXCHAIN_VALID(x)		(((x) & IWN_ANT_ABC) << 1)
+#define IWN_RXCHAIN_FORCE_SEL(x)	(((x) & IWN_ANT_ABC) << 4)
+#define IWN_RXCHAIN_FORCE_MIMO_SEL(x)	(((x) & IWN_ANT_ABC) << 7)
 #define IWN_RXCHAIN_IDLE_COUNT(x)	((x) << 10)
 #define IWN_RXCHAIN_MIMO_COUNT(x)	((x) << 12)
 #define IWN_RXCHAIN_MIMO_FORCE		(1 << 14)
-- 
cgit v1.2.3