Source-Changes-HG archive

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

[src/trunk]: src/sys Update for latest dwc2



details:   https://anonhg.NetBSD.org/src/rev/33c578fcab5e
branches:  trunk
changeset: 340298:33c578fcab5e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Aug 30 13:02:42 2015 +0000

description:
Update for latest dwc2

diffstat:

 sys/arch/arm/amlogic/amlogic_dwctwo.c    |    6 +-
 sys/arch/arm/broadcom/bcm2835_dwctwo.c   |    6 +-
 sys/arch/arm/rockchip/rockchip_dwctwo.c  |    6 +-
 sys/arch/mips/cavium/dev/octeon_dwctwo.c |    6 +-
 sys/arch/mips/ingenic/ingenic_dwctwo.c   |    6 +-
 sys/external/bsd/dwc2/dwc2.c             |  119 ++++++++++++++++++++++++++----
 sys/external/bsd/dwc2/dwc2.h             |   74 +++++++++++++++++++-
 7 files changed, 193 insertions(+), 30 deletions(-)

diffs (truncated from 457 to 300 lines):

diff -r 39b3a3c5944e -r 33c578fcab5e sys/arch/arm/amlogic/amlogic_dwctwo.c
--- a/sys/arch/arm/amlogic/amlogic_dwctwo.c     Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_dwctwo.c     Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amlogic_dwctwo.c,v 1.4 2015/07/30 07:32:40 skrll Exp $ */
+/*     $NetBSD: amlogic_dwctwo.c,v 1.5 2015/08/30 13:02:42 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_dwctwo.c,v 1.4 2015/07/30 07:32:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_dwctwo.c,v 1.5 2015/08/30 13:02:42 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,6 +85,8 @@
        .reload_ctl                     = -1,   /* 0 - No (default for core < 2.92a) */
        .ahbcfg                         = 0x3,  /* INCR4 */
        .uframe_sched                   = 1,    /* True to enable microframe scheduler */
+       .external_id_pin_ctl            = -1,
+       .hibernation                    = -1,
 };
 
 static int amlogic_dwctwo_match(device_t, struct cfdata *, void *);
diff -r 39b3a3c5944e -r 33c578fcab5e sys/arch/arm/broadcom/bcm2835_dwctwo.c
--- a/sys/arch/arm/broadcom/bcm2835_dwctwo.c    Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_dwctwo.c    Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_dwctwo.c,v 1.5 2015/07/30 07:32:40 skrll Exp $ */
+/*     $NetBSD: bcm2835_dwctwo.c,v 1.6 2015/08/30 13:02:42 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_dwctwo.c,v 1.5 2015/07/30 07:32:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_dwctwo.c,v 1.6 2015/08/30 13:02:42 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,6 +84,8 @@
        .reload_ctl                     = 0,
        .ahbcfg                         = 0x10,
        .uframe_sched                   = 1,
+       .external_id_pin_ctl            = -1,
+       .hibernation                    = -1,
 };
 
 static int bcmdwc2_match(device_t, struct cfdata *, void *);
diff -r 39b3a3c5944e -r 33c578fcab5e sys/arch/arm/rockchip/rockchip_dwctwo.c
--- a/sys/arch/arm/rockchip/rockchip_dwctwo.c   Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/arch/arm/rockchip/rockchip_dwctwo.c   Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rockchip_dwctwo.c,v 1.4 2015/07/30 07:32:40 skrll Exp $        */
+/*     $NetBSD: rockchip_dwctwo.c,v 1.5 2015/08/30 13:02:42 skrll Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rockchip_dwctwo.c,v 1.4 2015/07/30 07:32:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rockchip_dwctwo.c,v 1.5 2015/08/30 13:02:42 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,6 +84,8 @@
        .reload_ctl                     = 0,    /* 0 - No (default for core < 2.92a) */
        .ahbcfg                         = 0x7,  /* INCR16 */
        .uframe_sched                   = 1,    /* True to enable microframe scheduler */
+       .external_id_pin_ctl            = -1,
+       .hibernation                    = -1,
 };
 
 static int rkdwc2_match(device_t, struct cfdata *, void *);
diff -r 39b3a3c5944e -r 33c578fcab5e sys/arch/mips/cavium/dev/octeon_dwctwo.c
--- a/sys/arch/mips/cavium/dev/octeon_dwctwo.c  Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_dwctwo.c  Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: octeon_dwctwo.c,v 1.5 2015/07/30 07:32:40 skrll Exp $  */
+/*     $NetBSD: octeon_dwctwo.c,v 1.6 2015/08/30 13:02:42 skrll Exp $  */
 
 /*
  * Copyright (c) 2015 Masao Uebayashi <uebayasi%tombiinc.com@localhost>
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_dwctwo.c,v 1.5 2015/07/30 07:32:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_dwctwo.c,v 1.6 2015/08/30 13:02:42 skrll Exp $");
 
 #include "opt_octeon.h"
 #include "opt_usb.h"
@@ -135,6 +135,8 @@
        .reload_ctl                     = 0,
        .ahbcfg                         = 0,    /* XXX */
        .uframe_sched                   = 1,
+       .external_id_pin_ctl            = -1,
+       .hibernation                    = -1,
 };
 
 CFATTACH_DECL_NEW(octeon_dwctwo, sizeof(struct octeon_dwc2_softc),
diff -r 39b3a3c5944e -r 33c578fcab5e sys/arch/mips/ingenic/ingenic_dwctwo.c
--- a/sys/arch/mips/ingenic/ingenic_dwctwo.c    Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_dwctwo.c    Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ingenic_dwctwo.c,v 1.11 2015/05/18 15:11:47 macallan Exp $ */
+/*     $NetBSD: ingenic_dwctwo.c,v 1.12 2015/08/30 13:02:42 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_dwctwo.c,v 1.11 2015/05/18 15:11:47 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_dwctwo.c,v 1.12 2015/08/30 13:02:42 skrll Exp $");
 
 /*
  * adapted from bcm2835_dwctwo.c
@@ -87,6 +87,8 @@
        .reload_ctl                     = -1,
        .ahbcfg                         = -1,
        .uframe_sched                   = 0,
+       .external_id_pin_ctl            = -1,
+       .hibernation                    = -1,
 };
 
 static int ingenic_dwc2_match(device_t, struct cfdata *, void *);
diff -r 39b3a3c5944e -r 33c578fcab5e sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c      Sun Aug 30 12:59:59 2015 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c      Sun Aug 30 13:02:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwc2.c,v 1.36 2015/08/30 10:48:15 skrll Exp $  */
+/*     $NetBSD: dwc2.c,v 1.37 2015/08/30 13:02:42 skrll Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.36 2015/08/30 10:48:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.37 2015/08/30 13:02:42 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -1241,7 +1241,7 @@
 
        uint32_t flags = 0;
        uint32_t off = 0;
-       int retval, err = USBD_IN_PROGRESS;
+       int retval, err;
        int alloc_bandwidth = 0;
        int i;
 
@@ -1298,6 +1298,8 @@
        memset(dwc2_urb, 0, sizeof(*dwc2_urb) +
            sizeof(dwc2_urb->iso_descs[0]) * DWC2_MAXISOCPACKETS);
 
+       dwc2_urb->priv = xfer;
+
        dwc2_hcd_urb_set_pipeinfo(hsotg, dwc2_urb, addr, epnum, xfertype, dir,
                                  mps);
 
@@ -1378,6 +1380,28 @@
                off += xfer->frlengths[i];
        }
 
+       struct dwc2_qh *qh = dpipe->priv;
+       struct dwc2_qtd *qtd;
+       bool qh_allocated = false;
+
+       /* Create QH for the endpoint if it doesn't exist */
+       if (!qh) {
+               qh = dwc2_hcd_qh_create(hsotg, dwc2_urb, GFP_ATOMIC);
+               if (!qh) {
+                       retval = -ENOMEM;
+                       goto fail;
+               }
+               dpipe->priv = qh;
+               qh_allocated = true;
+       }
+
+       qtd = pool_cache_get(sc->sc_qtdpool, PR_NOWAIT);
+       if (!qtd) {
+               retval = -ENOMEM;
+               goto fail1;
+       }
+       memset(qtd, 0, sizeof(*qtd));
+
        /* might need to check cpu_intr_p */
        mutex_spin_enter(&hsotg->lock);
 
@@ -1385,11 +1409,9 @@
                callout_reset(&xfer->timeout_handle, mstohz(xfer->timeout),
                    dwc2_timeout, xfer);
        }
-
-       dwc2_urb->priv = xfer;
-       retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, &dpipe->priv, 0);
+       retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, qtd);
        if (retval)
-               goto fail;
+               goto fail2;
 
        if (alloc_bandwidth) {
                dwc2_allocate_bus_bandwidth(hsotg,
@@ -1397,14 +1419,25 @@
                                xfer);
        }
 
-fail:
        mutex_spin_exit(&hsotg->lock);
-
 //     mutex_exit(&sc->sc_lock);
 
+       return USBD_IN_PROGRESS;
+
+fail2:
+       dwc2_urb->priv = NULL;
+       mutex_spin_exit(&hsotg->lock);
+       pool_cache_put(sc->sc_qtdpool, qtd);
+
+fail1:
+       if (qh_allocated) {
+               dpipe->priv = NULL;
+               dwc2_hcd_qh_free(hsotg, qh);
+       }
+fail:
+
        switch (retval) {
-       case 0:
-               break;
+       case -EINVAL:
        case -ENODEV:
                err = USBD_INVAL;
                break;
@@ -1419,6 +1452,7 @@
 
 }
 
+#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
 void
 dwc2_worker(struct work *wk, void *priv)
 {
@@ -1455,6 +1489,7 @@
        }
        mutex_exit(&sc->sc_lock);
 }
+#endif
 
 int dwc2_intr(void *p)
 {
@@ -1600,15 +1635,66 @@
        sc->sc_hsotg->dev = sc->sc_dev;
        sc->sc_hcdenabled = true;
 
-       err = dwc2_hcd_init(sc->sc_hsotg, sc->sc_params);
-       if (err) {
-               err = -err;
+       struct dwc2_hsotg *hsotg = sc->sc_hsotg;
+       struct dwc2_core_params defparams;
+       int retval;
+
+       if (sc->sc_params == NULL) {
+               /* Default all params to autodetect */
+               dwc2_set_all_params(&defparams, -1);
+               sc->sc_params = &defparams;
+
+               /*
+                * Disable descriptor dma mode by default as the HW can support
+                * it, but does not support it for SPLIT transactions.
+                */
+               defparams.dma_desc_enable = 0;
+       }
+       hsotg->dr_mode = USB_DR_MODE_HOST;
+
+       /* Detect config values from hardware */
+       retval = dwc2_get_hwparams(hsotg);
+       if (retval) {
+               goto fail2;
+       }
+
+       hsotg->core_params = kmem_zalloc(sizeof(*hsotg->core_params), KM_SLEEP);
+       if (!hsotg->core_params) {
+               retval = -ENOMEM;
                goto fail2;
        }
 
+       dwc2_set_all_params(hsotg->core_params, -1);
+
+       /* Validate parameter values */
+       dwc2_set_parameters(hsotg, sc->sc_params);



Home | Main Index | Thread Index | Old Index