Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Sep 2015 05:48:52 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r288094 - head/sys/dev/usb/wlan
Message-ID:  <201509220548.t8M5mq82058264@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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,



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