From owner-freebsd-usb@FreeBSD.ORG Thu Apr 17 04:50:01 2014 Return-Path: Delivered-To: freebsd-usb@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 443FF8E9 for ; Thu, 17 Apr 2014 04:50:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 163451234 for ; Thu, 17 Apr 2014 04:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3H4o0nj068796 for ; Thu, 17 Apr 2014 04:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3H4o0L0068795; Thu, 17 Apr 2014 04:50:00 GMT (envelope-from gnats) Date: Thu, 17 Apr 2014 04:50:00 GMT Message-Id: <201404170450.s3H4o0L0068795@freefall.freebsd.org> To: freebsd-usb@FreeBSD.org Cc: From: John Wehle Subject: Re: usb/188683: dwc_otg FDT support for specifying usb controller mode X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: John Wehle List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2014 04:50:01 -0000 The following reply was made to PR usb/188683; it has been noted by GNATS. From: John Wehle To: ian@FreeBSD.org Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: usb/188683: dwc_otg FDT support for specifying usb controller mode Date: Thu, 17 Apr 2014 00:27:49 -0400 (EDT) > - dr_mode: tells Dual-Role USB controllers that we want to work on a > particular mode. Valid arguments are "host", "peripheral" and "otg". In > case this attribute isn't passed via DT, USB DRD controllers should > default to OTG. Patch revised per your comments attached below. -- John --------------------8<------------------------8<------------------------- Index: sys/dev/usb/controller/dwc_otg_fdt.c =================================================================== --- sys/dev/usb/controller/dwc_otg_fdt.c (revision 264251) +++ sys/dev/usb/controller/dwc_otg_fdt.c (working copy) @@ -91,9 +91,27 @@ dwc_otg_attach(device_t dev) { struct dwc_otg_super_softc *sc = device_get_softc(dev); + pcell_t *prop; + phandle_t node; + ssize_t len; int err; int rid; + node = ofw_bus_get_node(dev); + len = OF_getprop_alloc(node, "dr_mode", sizeof(char), (void **)&prop); + if (len >= 0) { + if (strcmp((char *)prop, "host") == 0) + sc->sc_otg.sc_mode = DWC_MODE_HOST; + else if (strcmp((char *)prop, "peripheral") == 0) + sc->sc_otg.sc_mode = DWC_MODE_DEVICE; + else if (strcmp((char *)prop, "otg") == 0) + ; + else + device_printf(dev, + "ignoring unknown value for dr_mode attribute in FDT\n"); + } + free(prop, M_OFWPROP); + /* initialise some bus fields */ sc->sc_otg.sc_bus.parent = dev; sc->sc_otg.sc_bus.devices = sc->sc_otg.sc_devices; Index: sys/dev/usb/controller/dwc_otg.c =================================================================== --- sys/dev/usb/controller/dwc_otg.c (revision 264251) +++ sys/dev/usb/controller/dwc_otg.c (working copy) @@ -2332,7 +2332,7 @@ DPRINTFN(5, "GOTGCTL=0x%08x\n", temp); - dwc_otg_vbus_interrupt(sc, + dwc_otg_vbus_interrupt(sc, (sc->sc_mode == DWC_MODE_HOST) ? 1 : (temp & (GOTGCTL_ASESVLD | GOTGCTL_BSESVLD)) ? 1 : 0); } @@ -3182,7 +3182,7 @@ sc->sc_host_ch_max); /* setup FIFO */ - if (dwc_otg_init_fifo(sc, DWC_MODE_OTG)) + if (dwc_otg_init_fifo(sc, sc->sc_mode)) return (EINVAL); /* enable interrupts */ @@ -3233,7 +3233,7 @@ DPRINTFN(5, "GOTCTL=0x%08x\n", temp); - dwc_otg_vbus_interrupt(sc, + dwc_otg_vbus_interrupt(sc, (sc->sc_mode == DWC_MODE_HOST) ? 1 : (temp & (GOTGCTL_ASESVLD | GOTGCTL_BSESVLD)) ? 1 : 0); USB_BUS_UNLOCK(&sc->sc_bus); ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | -------------------------------------------------------------------------