Author: avos
Date: Mon Feb 22 00:48:53 2016
New Revision: 295871
URL: https://svnweb.freebsd.org/changeset/base/295871

Log:
  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

Modified:
  head/sys/conf/options
  head/sys/dev/usb/wlan/if_urtwn.c
  head/sys/dev/usb/wlan/if_urtwnvar.h
  head/sys/modules/usb/Makefile
  head/sys/modules/usb/urtwn/Makefile

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options       Sun Feb 21 22:34:09 2016        (r295870)
+++ head/sys/conf/options       Mon Feb 22 00:48:53 2016        (r295871)
@@ -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
 

Modified: head/sys/dev/usb/wlan/if_urtwn.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwn.c    Sun Feb 21 22:34:09 2016        
(r295870)
+++ head/sys/dev/usb/wlan/if_urtwn.c    Mon Feb 22 00:48:53 2016        
(r295871)
@@ -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 ieee802
 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, uin
        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);

Modified: head/sys/dev/usb/wlan/if_urtwnvar.h
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwnvar.h Sun Feb 21 22:34:09 2016        
(r295870)
+++ head/sys/dev/usb/wlan/if_urtwnvar.h Mon Feb 22 00:48:53 2016        
(r295871)
@@ -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;
 

Modified: head/sys/modules/usb/Makefile
==============================================================================
--- head/sys/modules/usb/Makefile       Sun Feb 21 22:34:09 2016        
(r295870)
+++ head/sys/modules/usb/Makefile       Mon Feb 22 00:48:53 2016        
(r295871)
@@ -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

Modified: head/sys/modules/usb/urtwn/Makefile
==============================================================================
--- head/sys/modules/usb/urtwn/Makefile Sun Feb 21 22:34:09 2016        
(r295870)
+++ head/sys/modules/usb/urtwn/Makefile Mon Feb 22 00:48:53 2016        
(r295871)
@@ -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>
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to