Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add support for Realtek 8192EU.



details:   https://anonhg.NetBSD.org/src/rev/ae7bee098409
branches:  trunk
changeset: 348254:ae7bee098409
user:      nat <nat%NetBSD.org@localhost>
date:      Wed Oct 12 03:23:29 2016 +0000

description:
Add support for Realtek 8192EU.

OK christos@

diffstat:

 share/man/man4/urtwn.4      |   12 +-
 sys/dev/usb/if_urtwn.c      |  587 +++++++++++++++++++++++++++++++++----------
 sys/dev/usb/if_urtwn_data.h |  223 ++++++++++++++++-
 sys/dev/usb/if_urtwnreg.h   |   87 ++++++-
 sys/dev/usb/if_urtwnvar.h   |   20 +-
 5 files changed, 775 insertions(+), 154 deletions(-)

diffs (truncated from 1928 to 300 lines):

diff -r 77f8b253958a -r ae7bee098409 share/man/man4/urtwn.4
--- a/share/man/man4/urtwn.4    Wed Oct 12 03:12:03 2016 +0000
+++ b/share/man/man4/urtwn.4    Wed Oct 12 03:23:29 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: urtwn.4,v 1.14 2014/07/25 15:07:03 nonaka Exp $
+.\" $NetBSD: urtwn.4,v 1.15 2016/10/12 03:23:29 nat Exp $
 .\" $OpenBSD: urtwn.4,v 1.15 2011/11/26 06:39:33 ckuethe Exp $
 .\"
 .\" Copyright (c) 2010 Damien Bergamini <damien.bergamini%free.fr@localhost>
@@ -20,14 +20,15 @@
 .Os
 .Sh NAME
 .Nm urtwn
-.Nd Realtek RTL8188CU/RTL8188EU/RTL8192CU USB IEEE 802.11b/g/n wireless network device
+.Nd Realtek RTL8188CU/RTL8188EU/RTL8192CU/RTL8192EU USB IEEE 802.11b/g/n wireless network device
 .Sh SYNOPSIS
 .Cd "urtwn* at uhub? port ?"
 .Sh DESCRIPTION
 The
 .Nm
 driver supports USB 2.0 wireless network devices based on Realtek
-RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU, and RTL8192CU chipsets.
+RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU, RTL8192CU and RTL8192EU
+chipsets.
 .Pp
 The RTL8188CUS and RTL8188EUS are highly integrated 802.11n adapters that
 combine a MAC, a 1T1R capable baseband and an RF in a single chip.
@@ -36,8 +37,8 @@
 The RTL8188CE-VAU is a PCI Express Mini Card adapter that attaches
 to the USB interface.
 .Pp
-The RTL8192CU is a highly integrated multiple-in, multiple-out (MIMO)
-802.11n adapter that combines a MAC, a 2T2R capable baseband and an
+The RTL8192CU and RTL8192EU are highly integrated multiple-in, multiple-out
+(MIMO) 802.11n adapters that combine a MAC, a 2T2R capable baseband and an
 RF in a single chip.
 It operates in the 2GHz spectrum only.
 .Pp
@@ -96,6 +97,7 @@
 .It /libdata/firmware/if_urtwn/rtl8188eufw.bin
 .It /libdata/firmware/if_urtwn/rtl8192cfw.bin
 .It /libdata/firmware/if_urtwn/rtl8192cfwU.bin
+.It /libdata/firmware/if_urtwn/rtl8192efw.bin
 .El
 .Sh HARDWARE
 The following adapters should work:
diff -r 77f8b253958a -r ae7bee098409 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Wed Oct 12 03:12:03 2016 +0000
+++ b/sys/dev/usb/if_urtwn.c    Wed Oct 12 03:23:29 2016 +0000
@@ -1,9 +1,10 @@
-/*     $NetBSD: if_urtwn.c,v 1.48 2016/10/12 02:56:45 nat Exp $        */
+/*     $NetBSD: if_urtwn.c,v 1.49 2016/10/12 03:23:29 nat Exp $        */
 /*     $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $       */
 
 /*-
  * Copyright (c) 2010 Damien Bergamini <damien.bergamini%free.fr@localhost>
  * Copyright (c) 2014 Kevin Lo <kevlo%FreeBSD.org@localhost>
+ * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -19,11 +20,12 @@
  */
 
 /*-
- * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU.
+ * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU
+ * RTL8192EU.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.48 2016/10/12 02:56:45 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.49 2016/10/12 03:23:29 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -99,10 +101,13 @@
 #define URTWN_DEV(v,p) { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, 0 }
 #define URTWN_RTL8188E_DEV(v,p) \
        { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, FLAG_RTL8188E }
+#define URTWN_RTL8192EU_DEV(v,p) \
+       { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, FLAG_RTL8192E }
 static const struct urtwn_dev {
        struct usb_devno        dev;
        uint32_t                flags;
 #define        FLAG_RTL8188E   __BIT(0)
+#define        FLAG_RTL8192E   __BIT(1)
 } urtwn_devs[] = {
        URTWN_DEV(ABOCOM,       RTL8188CU_1),
        URTWN_DEV(ABOCOM,       RTL8188CU_2),
@@ -184,9 +189,13 @@
        URTWN_RTL8188E_DEV(ELECOM, WDC150SU2M),
        URTWN_RTL8188E_DEV(REALTEK, RTL8188ETV),
        URTWN_RTL8188E_DEV(REALTEK, RTL8188EU),
+       
+       /* URTWN_RTL8192EU */
+       URTWN_RTL8192EU_DEV(REALTEK,    RTL8192EU),
 };
 #undef URTWN_DEV
 #undef URTWN_RTL8188E_DEV
+#undef URTWN_RTL8192EU_DEV
 
 static int     urtwn_match(device_t, cfdata_t, void *);
 static void    urtwn_attach(device_t, device_t, void *);
@@ -223,6 +232,8 @@
                    uint32_t);
 static void    urtwn_r88e_rf_write(struct urtwn_softc *, int, uint8_t,
                    uint32_t);
+static void    urtwn_r92e_rf_write(struct urtwn_softc *, int, uint8_t,
+                   uint32_t);
 static uint32_t        urtwn_rf_read(struct urtwn_softc *, int, uint8_t);
 static int     urtwn_llt_write(struct urtwn_softc *, uint32_t, uint32_t);
 static uint8_t urtwn_efuse_read_1(struct urtwn_softc *, uint16_t);
@@ -262,6 +273,7 @@
 static void    urtwn_watchdog(struct ifnet *);
 static int     urtwn_ioctl(struct ifnet *, u_long, void *);
 static int     urtwn_r92c_power_on(struct urtwn_softc *);
+static int     urtwn_r92e_power_on(struct urtwn_softc *);
 static int     urtwn_r88e_power_on(struct urtwn_softc *);
 static int     urtwn_llt_init(struct urtwn_softc *);
 static void    urtwn_fw_reset(struct urtwn_softc *);
@@ -293,6 +305,7 @@
 static int     urtwn_reset(struct ifnet *);
 static void    urtwn_chip_stop(struct urtwn_softc *);
 static void    urtwn_newassoc(struct ieee80211_node *, int);
+static void    urtwn_delay_ms(struct urtwn_softc *, int ms);
 
 /* Aliases. */
 #define        urtwn_bb_write  urtwn_write_4
@@ -313,8 +326,8 @@
 {
        struct usb_attach_arg *uaa = aux;
 
-       return urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL ?
-           UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
+       return urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product) !=
+           NULL ?  UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
 }
 
 static void
@@ -337,6 +350,8 @@
        dev = urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product);
        if (dev != NULL && ISSET(dev->flags, FLAG_RTL8188E))
                SET(sc->chip, URTWN_CHIP_88E);
+       if (dev != NULL && ISSET(dev->flags, FLAG_RTL8192E))
+               SET(sc->chip, URTWN_CHIP_92EU);
 
        aprint_naive("\n");
        aprint_normal("\n");
@@ -357,6 +372,7 @@
 
        mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
        mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_NONE);
+       mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_NONE);
        mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
        mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
 
@@ -391,17 +407,22 @@
        if (sc->chip & URTWN_CHIP_92C) {
                sc->ntxchains = (sc->chip & URTWN_CHIP_92C_1T2R) ? 1 : 2;
                sc->nrxchains = 2;
+       } else if (sc->chip & URTWN_CHIP_92EU) {
+               sc->ntxchains = 2;
+               sc->nrxchains = 2;
        } else {
                sc->ntxchains = 1;
                sc->nrxchains = 1;
        }
 
-       if (ISSET(sc->chip, URTWN_CHIP_88E))
+       if (ISSET(sc->chip, URTWN_CHIP_88E) ||
+           ISSET(sc->chip, URTWN_CHIP_92EU))
                urtwn_r88e_read_rom(sc);
        else
                urtwn_read_rom(sc);
 
        aprint_normal_dev(self, "MAC/BB RTL%s, RF 6052 %zdT%zdR, address %s\n",
+           (sc->chip & URTWN_CHIP_92EU) ? "8192EU" :
            (sc->chip & URTWN_CHIP_92C) ? "8192CU" :
            (sc->chip & URTWN_CHIP_88E) ? "8188EU" :
            (sc->board_type == R92C_BOARD_TYPE_HIGHPA) ? "8188RU" :
@@ -539,6 +560,7 @@
        mutex_destroy(&sc->sc_write_mtx);
        mutex_destroy(&sc->sc_fwcmd_mtx);
        mutex_destroy(&sc->sc_tx_mtx);
+       mutex_destroy(&sc->sc_rx_mtx);
        mutex_destroy(&sc->sc_task_mtx);
 
        return 0;
@@ -564,10 +586,11 @@
 urtwn_open_pipes(struct urtwn_softc *sc)
 {
        /* Bulk-out endpoints addresses (from highest to lowest prio). */
-       static const uint8_t epaddr[] = { 0x02, 0x03, 0x05 };
+       static uint8_t epaddr[3];
+       static uint8_t rxepaddr[3];
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
-       size_t i, ntx = 0;
+       size_t i, ntx = 0, nrx = 0;
        int error;
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -578,8 +601,16 @@
                ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
                if (ed != NULL &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK &&
-                   UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT)
+                   UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT) {
+                       epaddr[ntx] = ed->bEndpointAddress;
                        ntx++;
+               }
+               if (ed != NULL &&
+                   UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK &&
+                   UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) {
+                       rxepaddr[nrx] = ed->bEndpointAddress;
+                       nrx++;
+               }
        }
        DPRINTFN(DBG_INIT, ("%s: %s: found %zd bulk-out pipes\n",
            device_xname(sc->sc_dev), __func__, ntx));
@@ -588,16 +619,19 @@
                    "%zd: invalid number of Tx bulk pipes\n", ntx);
                return EIO;
        }
-       sc->rx_npipe = 1;
+       sc->rx_npipe = nrx;
        sc->tx_npipe = ntx;
 
        /* Open bulk-in pipe at address 0x81. */
-       error = usbd_open_pipe(sc->sc_iface, 0x81, USBD_EXCLUSIVE_USE,
-           &sc->rx_pipe);
-       if (error != 0) {
-               aprint_error_dev(sc->sc_dev, "could not open Rx bulk pipe"
-                   ": %d\n", error);
-               goto fail;
+       for (i = 0; i < nrx; i++) {
+               error = usbd_open_pipe(sc->sc_iface, rxepaddr[i],
+                   USBD_EXCLUSIVE_USE, &sc->rx_pipe[i]);
+               if (error != 0) {
+                       aprint_error_dev(sc->sc_dev,
+                           "could not open Rx bulk pipe 0x%02x: %d\n",
+                           rxepaddr[i], error);
+                       goto fail;
+               }
        }
 
        /* Open bulk-out pipes (up to 3). */
@@ -632,14 +666,17 @@
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
-       /* Close Rx pipe. */
+       /* Close Rx pipes. */
        CTASSERT(sizeof(pipe) == sizeof(void *));
-       pipe = atomic_swap_ptr(&sc->rx_pipe, NULL);
-       if (pipe != NULL) {
-               usbd_close_pipe(pipe);
+       for (i = 0; i < sc->rx_npipe; i++) {
+               pipe = atomic_swap_ptr(&sc->rx_pipe[i], NULL);
+               if (pipe != NULL) {
+                       usbd_close_pipe(pipe);
+               }
        }
+
        /* Close Tx pipes. */
-       for (i = 0; i < R92C_MAX_EPOUT; i++) {
+       for (i = 0; i < sc->tx_npipe; i++) {
                pipe = atomic_swap_ptr(&sc->tx_pipe[i], NULL);
                if (pipe != NULL) {
                        usbd_close_pipe(pipe);
@@ -656,20 +693,24 @@
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
 
-       for (i = 0; i < URTWN_RX_LIST_COUNT; i++) {
-               data = &sc->rx_data[i];
-
-               data->sc = sc;  /* Backpointer for callbacks. */
-
-               error = usbd_create_xfer(sc->rx_pipe, URTWN_RXBUFSZ,
-                   USBD_SHORT_XFER_OK, 0, &data->xfer);
-               if (error) {
-                       aprint_error_dev(sc->sc_dev,
-                           "could not allocate xfer\n");
-                       break;
+       for (size_t j = 0; j < sc->rx_npipe; j++) {
+               TAILQ_INIT(&sc->rx_free_list[j]);
+               for (i = 0; i < URTWN_RX_LIST_COUNT; i++) {
+                       data = &sc->rx_data[j][i];
+
+                       data->sc = sc;  /* Backpointer for callbacks. */
+
+                       error = usbd_create_xfer(sc->rx_pipe[j], URTWN_RXBUFSZ,
+                           USBD_SHORT_XFER_OK, 0, &data->xfer);
+                       if (error) {
+                               aprint_error_dev(sc->sc_dev,
+                                   "could not allocate xfer\n");
+                               break;
+                       }



Home | Main Index | Thread Index | Old Index