From owner-svn-src-all@freebsd.org Fri Oct 23 08:26:28 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 24696A1A666; Fri, 23 Oct 2015 08:26:28 +0000 (UTC) (envelope-from avos@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 D3E08F40; Fri, 23 Oct 2015 08:26:27 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9N8QQCG088759; Fri, 23 Oct 2015 08:26:26 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9N8QQgU088757; Fri, 23 Oct 2015 08:26:26 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201510230826.t9N8QQgU088757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Fri, 23 Oct 2015 08:26:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289811 - head/sys/dev/usb/wlan 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: Fri, 23 Oct 2015 08:26:28 -0000 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