From owner-svn-src-head@freebsd.org Tue Sep 22 05:48:52 2015 Return-Path: Delivered-To: svn-src-head@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 E08A1A0534C; Tue, 22 Sep 2015 05:48:52 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 B7C391F69; Tue, 22 Sep 2015 05:48:52 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8M5mqBP058266; Tue, 22 Sep 2015 05:48:52 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8M5mq82058264; Tue, 22 Sep 2015 05:48:52 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201509220548.t8M5mq82058264@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 22 Sep 2015 05:48:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288094 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 05:48:53 -0000 Author: adrian Date: Tue Sep 22 05:48:51 2015 New Revision: 288094 URL: https://svnweb.freebsd.org/changeset/base/288094 Log: Send a power command to the firmware to shut down the radio as well during rsu_stop(). Modified: head/sys/dev/usb/wlan/if_rsu.c head/sys/dev/usb/wlan/if_rsureg.h Modified: head/sys/dev/usb/wlan/if_rsu.c ============================================================================== --- head/sys/dev/usb/wlan/if_rsu.c Tue Sep 22 05:05:53 2015 (r288093) +++ head/sys/dev/usb/wlan/if_rsu.c Tue Sep 22 05:48:51 2015 (r288094) @@ -1088,6 +1088,7 @@ rsu_tx_task(void *arg, int pending __unu RSU_UNLOCK(sc); } +#define RSU_PWR_UNKNOWN 0x0 #define RSU_PWR_ACTIVE 0x1 #define RSU_PWR_OFF 0x2 #define RSU_PWR_SLEEP 0x3 @@ -1116,11 +1117,14 @@ rsu_set_fw_power_state(struct rsu_softc //struct r92s_pwr_cmd cmd; int error; - memset(&cmd, 0, sizeof(cmd)); - - /* XXX TODO: only change state if required */ RSU_ASSERT_LOCKED(sc); + /* only change state if required */ + if (sc->sc_curpwrstate == state) + return (0); + + memset(&cmd, 0, sizeof(cmd)); + switch (state) { case RSU_PWR_ACTIVE: /* Force the hardware awake */ @@ -1133,6 +1137,9 @@ rsu_set_fw_power_state(struct rsu_softc cmd.smart_ps = 1; /* XXX 2 if doing p2p */ cmd.bcn_pass_time = 5; /* in 100mS usb.c, linux/rtlwifi */ break; + case RSU_PWR_OFF: + cmd.mode = R92S_PS_MODE_RADIOOFF; + break; default: device_printf(sc->sc_dev, "%s: unknown ps mode (%d)\n", __func__, @@ -1144,6 +1151,8 @@ rsu_set_fw_power_state(struct rsu_softc "%s: setting ps mode to %d (mode %d)\n", __func__, state, cmd.mode); error = rsu_fw_cmd(sc, R92S_CMD_SET_PWR_MODE, &cmd, sizeof(cmd)); + if (error == 0) + sc->sc_curpwrstate = state; return (error); } @@ -2460,6 +2469,9 @@ rsu_power_off(struct rsu_softc *sc) /* Disable 1.6V LDO. */ rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x56); rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x43); + + /* Firmware - tell it to switch things off */ + (void) rsu_set_fw_power_state(sc, RSU_PWR_OFF); } static int @@ -2828,6 +2840,8 @@ rsu_stop(struct rsu_softc *sc) { int i; + RSU_ASSERT_LOCKED(sc); + sc->sc_running = 0; sc->sc_calibrating = 0; taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL); Modified: head/sys/dev/usb/wlan/if_rsureg.h ============================================================================== --- head/sys/dev/usb/wlan/if_rsureg.h Tue Sep 22 05:05:53 2015 (r288093) +++ head/sys/dev/usb/wlan/if_rsureg.h Tue Sep 22 05:48:51 2015 (r288094) @@ -749,6 +749,7 @@ struct rsu_softc { struct mtx sc_mtx; int sc_ht; int sc_nendpoints; + int sc_curpwrstate; u_int sc_running:1, sc_calibrating:1,