summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravos <avos@FreeBSD.org>2016-02-22 00:48:53 +0000
committeravos <avos@FreeBSD.org>2016-02-22 00:48:53 +0000
commit6453e45ba937bd756572ef0946949dc891ec597f (patch)
treec8c788415b37d87cf57f79d163e96bd6bcce3b94
parent69511675eb34650e2176ca75b267875494f017c3 (diff)
downloadFreeBSD-src-6453e45ba937bd756572ef0946949dc891ec597f.zip
FreeBSD-src-6453e45ba937bd756572ef0946949dc891ec597f.tar.gz
urtwn: add an option to compile the driver without firmware specific code
- Add URTWN_WITHOUT_UCODE option (will disable any firmware specific code when set). - Do not exclude the driver from build when MK_SOURCELESS_UCODE is set (URTWN_WITHOUT_UCODE will be enforced unconditionally). - Do not abort initialization when firmware cannot be loaded; behave like the URTWN_WITHOUT_UCODE option was set. - Drop some unused variables from urtwn_softc structure. Tested with RTL8188EU and RTL8188CUS in HOSTAP and STA modes. Reviewed by: kevlo Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D4849
-rw-r--r--sys/conf/options3
-rw-r--r--sys/dev/usb/wlan/if_urtwn.c23
-rw-r--r--sys/dev/usb/wlan/if_urtwnvar.h8
-rw-r--r--sys/modules/usb/Makefile3
-rw-r--r--sys/modules/usb/urtwn/Makefile9
5 files changed, 34 insertions, 12 deletions
diff --git a/sys/conf/options b/sys/conf/options
index f1b2af4..f7c48c2 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -673,6 +673,9 @@ UPLCOM_INTR_INTERVAL opt_uplcom.h
UVSCOM_DEFAULT_OPKTSIZE opt_uvscom.h
UVSCOM_INTR_INTERVAL opt_uvscom.h
+# options for the Realtek RTL8188*U/RTL8192CU driver (urtwn)
+URTWN_WITHOUT_UCODE opt_urtwn.h
+
# Embedded system options
INIT_PATH
diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c
index a6a8f50..fa93210 100644
--- a/sys/dev/usb/wlan/if_urtwn.c
+++ b/sys/dev/usb/wlan/if_urtwn.c
@@ -26,6 +26,7 @@ __FBSDID("$FreeBSD$");
*/
#include "opt_wlan.h"
+#include "opt_urtwn.h"
#include <sys/param.h>
#include <sys/sockio.h>
@@ -308,11 +309,13 @@ static void urtwn_parent(struct ieee80211com *);
static int urtwn_r92c_power_on(struct urtwn_softc *);
static int urtwn_r88e_power_on(struct urtwn_softc *);
static int urtwn_llt_init(struct urtwn_softc *);
+#ifndef URTWN_WITHOUT_UCODE
static void urtwn_fw_reset(struct urtwn_softc *);
static void urtwn_r88e_fw_reset(struct urtwn_softc *);
static int urtwn_fw_loadpage(struct urtwn_softc *, int,
const uint8_t *, int);
static int urtwn_load_firmware(struct urtwn_softc *);
+#endif
static int urtwn_dma_init(struct urtwn_softc *);
static int urtwn_mac_init(struct urtwn_softc *);
static void urtwn_bb_init(struct urtwn_softc *);
@@ -1376,6 +1379,13 @@ urtwn_fw_cmd(struct urtwn_softc *sc, uint8_t id, const void *buf, int len)
usb_error_t error;
int ntries;
+ if (!(sc->sc_flags & URTWN_FW_LOADED)) {
+ URTWN_DPRINTF(sc, URTWN_DEBUG_FIRMWARE, "%s: firmware "
+ "was not loaded; command (id %d) will be discarded\n",
+ __func__, id);
+ return (0);
+ }
+
/* Wait for current FW box to be empty. */
for (ntries = 0; ntries < 100; ntries++) {
if (!(urtwn_read_1(sc, R92C_HMETFR) & (1 << sc->fwcur)))
@@ -3275,6 +3285,7 @@ urtwn_llt_init(struct urtwn_softc *sc)
return (error);
}
+#ifndef URTWN_WITHOUT_UCODE
static void
urtwn_fw_reset(struct urtwn_softc *sc)
{
@@ -3457,6 +3468,7 @@ fail:
firmware_put(fw, FIRMWARE_UNLOAD);
return (error);
}
+#endif
static int
urtwn_dma_init(struct urtwn_softc *sc)
@@ -4786,10 +4798,12 @@ urtwn_init(struct urtwn_softc *sc)
urtwn_write_1(sc, R92C_BCN_MAX_ERR, 0xff);
}
+#ifndef URTWN_WITHOUT_UCODE
/* Load 8051 microcode. */
error = urtwn_load_firmware(sc);
- if (error != 0)
- goto fail;
+ if (error == 0)
+ sc->sc_flags |= URTWN_FW_LOADED;
+#endif
/* Initialize MAC/BB/RF blocks. */
error = urtwn_mac_init(sc);
@@ -4892,7 +4906,8 @@ urtwn_stop(struct urtwn_softc *sc)
return;
}
- sc->sc_flags &= ~(URTWN_RUNNING | URTWN_TEMP_MEASURED);
+ sc->sc_flags &= ~(URTWN_RUNNING | URTWN_FW_LOADED |
+ URTWN_TEMP_MEASURED);
sc->thcal_lctemp = 0;
callout_stop(&sc->sc_watchdog_ch);
urtwn_abort_xfers(sc);
@@ -4991,6 +5006,8 @@ static devclass_t urtwn_devclass;
DRIVER_MODULE(urtwn, uhub, urtwn_driver, urtwn_devclass, NULL, NULL);
MODULE_DEPEND(urtwn, usb, 1, 1, 1);
MODULE_DEPEND(urtwn, wlan, 1, 1, 1);
+#ifndef URTWN_WITHOUT_UCODE
MODULE_DEPEND(urtwn, firmware, 1, 1, 1);
+#endif
MODULE_VERSION(urtwn, 1);
USB_PNP_HOST_INFO(urtwn_devs);
diff --git a/sys/dev/usb/wlan/if_urtwnvar.h b/sys/dev/usb/wlan/if_urtwnvar.h
index ac94f96..ce388d2 100644
--- a/sys/dev/usb/wlan/if_urtwnvar.h
+++ b/sys/dev/usb/wlan/if_urtwnvar.h
@@ -155,7 +155,8 @@ struct urtwn_softc {
uint8_t sc_flags;
#define URTWN_FLAG_CCK_HIPWR 0x01
#define URTWN_DETACHED 0x02
-#define URTWN_RUNNING 0x04
+#define URTWN_RUNNING 0x04
+#define URTWN_FW_LOADED 0x08
#define URTWN_TEMP_MEASURED 0x10
u_int chip;
@@ -196,11 +197,6 @@ struct urtwn_softc {
urtwn_datahead sc_tx_inactive;
urtwn_datahead sc_tx_pending;
- const char *fwname;
- const struct firmware *fw_fp;
- struct urtwn_fw_info fw;
- void *fw_virtaddr;
-
union urtwn_rom rom;
uint16_t last_rom_addr;
diff --git a/sys/modules/usb/Makefile b/sys/modules/usb/Makefile
index 8bb355b..b236d04 100644
--- a/sys/modules/usb/Makefile
+++ b/sys/modules/usb/Makefile
@@ -47,7 +47,7 @@ SUBDIR = usb
SUBDIR += ${_dwc_otg} ehci ${_musb} ohci uhci xhci ${_uss820dci} ${_at91dci} \
${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw} ${_saf1761otg}
SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw}
-SUBDIR += ${_urtwn} ${_urtwnfw}
+SUBDIR += urtwn ${_urtwnfw}
SUBDIR += atp uhid ukbd ums udbp ufm uep wsp ugold uled
SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
umct umcs umodem umoscom uplcom uslcom uvisor uvscom
@@ -70,7 +70,6 @@ _rum= rum
_uath= uath
_zyd= zyd
_kue= kue
-_urtwn= urtwn
_urtwnfw= urtwnfw
_run= run
_runfw= runfw
diff --git a/sys/modules/usb/urtwn/Makefile b/sys/modules/usb/urtwn/Makefile
index 656fab9..59fa910 100644
--- a/sys/modules/usb/urtwn/Makefile
+++ b/sys/modules/usb/urtwn/Makefile
@@ -2,9 +2,16 @@
.PATH: ${.CURDIR}/../../../dev/usb/wlan
+.include <src.opts.mk>
+
KMOD = if_urtwn
SRCS = if_urtwn.c if_urtwnreg.h if_urtwnvar.h \
bus_if.h device_if.h \
- opt_bus.h opt_usb.h opt_wlan.h usb_if.h usbdevs.h
+ opt_bus.h opt_urtwn.h opt_usb.h opt_wlan.h usb_if.h usbdevs.h
+
+.if ${MK_SOURCELESS_UCODE} == "no"
+opt_urtwn.h:
+ @echo "#define URTWN_WITHOUT_UCODE 1" > ${.TARGET}
+.endif
.include <bsd.kmod.mk>
OpenPOWER on IntegriCloud