Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Oct 2015 08:26:26 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289811 - head/sys/dev/usb/wlan
Message-ID:  <201510230826.t9N8QQgU088757@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Fri Oct 23 08:26:26 2015
New Revision: 289811
URL: https://svnweb.freebsd.org/changeset/base/289811

Log:
  - Split one 4-byte R92C_CR register into 2-byte R92C_CR and 1-byte R92C_MSR
  registers (they are used for different purposes).
  - Wrap R92C_MSR modifications into urtwn_set_mode().
  
  Reviewed by:	kevlo
  Approved by:	adrian (mentor)
  Differential Revision:	https://reviews.freebsd.org/D3838

Modified:
  head/sys/dev/usb/wlan/if_urtwn.c
  head/sys/dev/usb/wlan/if_urtwnreg.h

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwn.c	Fri Oct 23 08:16:10 2015	(r289810)
+++ head/sys/dev/usb/wlan/if_urtwn.c	Fri Oct 23 08:26:26 2015	(r289811)
@@ -222,6 +222,7 @@ static void		urtwn_r88e_read_rom(struct 
 static int		urtwn_ra_init(struct urtwn_softc *);
 static void		urtwn_tsf_sync_enable(struct urtwn_softc *);
 static void		urtwn_set_led(struct urtwn_softc *, int, int);
+static void		urtwn_set_mode(struct urtwn_softc *, uint8_t);
 static int		urtwn_newstate(struct ieee80211vap *,
 			    enum ieee80211_state, int);
 static void		urtwn_watchdog(void *);
@@ -1522,6 +1523,16 @@ urtwn_set_led(struct urtwn_softc *sc, in
 	}
 }
 
+static void
+urtwn_set_mode(struct urtwn_softc *sc, uint8_t mode)
+{
+	uint8_t reg;
+
+	reg = urtwn_read_1(sc, R92C_MSR);
+	reg = (reg & ~R92C_MSR_MASK) | mode;
+	urtwn_write_1(sc, R92C_MSR, reg);
+}
+
 static int
 urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
@@ -1530,7 +1541,6 @@ urtwn_newstate(struct ieee80211vap *vap,
 	struct urtwn_softc *sc = ic->ic_softc;
 	struct ieee80211_node *ni;
 	enum ieee80211_state ostate;
-	uint32_t reg;
 
 	ostate = vap->iv_state;
 	DPRINTF("%s -> %s\n", ieee80211_state_name[ostate],
@@ -1545,9 +1555,7 @@ urtwn_newstate(struct ieee80211vap *vap,
 		urtwn_set_led(sc, URTWN_LED_LINK, 0);
 
 		/* Set media status to 'No Link'. */
-		reg = urtwn_read_4(sc, R92C_CR);
-		reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_NOLINK);
-		urtwn_write_4(sc, R92C_CR, reg);
+		urtwn_set_mode(sc, R92C_MSR_NOLINK);
 
 		/* Stop Rx of data frames. */
 		urtwn_write_2(sc, R92C_RXFLTMAP2, 0);
@@ -1632,9 +1640,7 @@ urtwn_newstate(struct ieee80211vap *vap,
 
 		ni = ieee80211_ref_node(vap->iv_bss);
 		/* Set media status to 'Associated'. */
-		reg = urtwn_read_4(sc, R92C_CR);
-		reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_INFRA);
-		urtwn_write_4(sc, R92C_CR, reg);
+		urtwn_set_mode(sc, R92C_MSR_INFRA);
 
 		/* Set BSSID. */
 		urtwn_write_4(sc, R92C_BSSID + 0, LE_READ_4(&ni->ni_bssid[0]));
@@ -3294,9 +3300,7 @@ urtwn_init(struct urtwn_softc *sc)
 	urtwn_write_region_1(sc, R92C_MACID, macaddr, IEEE80211_ADDR_LEN);
 
 	/* Set initial network type. */
-	reg = urtwn_read_4(sc, R92C_CR);
-	reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_INFRA);
-	urtwn_write_4(sc, R92C_CR, reg);
+	urtwn_set_mode(sc, R92C_MSR_INFRA);
 
 	urtwn_rxfilter_init(sc);
 

Modified: head/sys/dev/usb/wlan/if_urtwnreg.h
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwnreg.h	Fri Oct 23 08:16:10 2015	(r289810)
+++ head/sys/dev/usb/wlan/if_urtwnreg.h	Fri Oct 23 08:26:26 2015	(r289811)
@@ -96,6 +96,7 @@
 #define R92C_SYS_CFG			0x0f0
 /* MAC General Configuration. */
 #define R92C_CR				0x100
+#define R92C_MSR			0x102
 #define R92C_PBP			0x104
 #define R92C_TRXDMA_CTRL		0x10c
 #define R92C_TRXFF_BNDY			0x114
@@ -377,22 +378,23 @@
 #define R92C_SYS_CFG_TYPE_92C		0x08000000
 
 /* Bits for R92C_CR. */
-#define R92C_CR_HCI_TXDMA_EN	0x00000001
-#define R92C_CR_HCI_RXDMA_EN	0x00000002
-#define R92C_CR_TXDMA_EN	0x00000004
-#define R92C_CR_RXDMA_EN	0x00000008
-#define R92C_CR_PROTOCOL_EN	0x00000010
-#define R92C_CR_SCHEDULE_EN	0x00000020
-#define R92C_CR_MACTXEN		0x00000040
-#define R92C_CR_MACRXEN		0x00000080
-#define R92C_CR_ENSEC		0x00000200
-#define R92C_CR_CALTMR_EN	0x00000400
-#define R92C_CR_NETTYPE_S	16
-#define R92C_CR_NETTYPE_M	0x00030000
-#define R92C_CR_NETTYPE_NOLINK	0
-#define R92C_CR_NETTYPE_ADHOC	1
-#define R92C_CR_NETTYPE_INFRA	2
-#define R92C_CR_NETTYPE_AP	3
+#define R92C_CR_HCI_TXDMA_EN	0x0001
+#define R92C_CR_HCI_RXDMA_EN	0x0002
+#define R92C_CR_TXDMA_EN	0x0004
+#define R92C_CR_RXDMA_EN	0x0008
+#define R92C_CR_PROTOCOL_EN	0x0010
+#define R92C_CR_SCHEDULE_EN	0x0020
+#define R92C_CR_MACTXEN		0x0040
+#define R92C_CR_MACRXEN		0x0080
+#define R92C_CR_ENSEC		0x0200
+#define R92C_CR_CALTMR_EN	0x0400
+
+/* Bits for R92C_MSR. */
+#define R92C_MSR_NOLINK		0x00
+#define R92C_MSR_ADHOC		0x01
+#define R92C_MSR_INFRA		0x02
+#define R92C_MSR_AP		0x03
+#define R92C_MSR_MASK		(R92C_MSR_AP)
 
 /* Bits for R92C_PBP. */
 #define R92C_PBP_PSRX_M		0x0f



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