From owner-freebsd-usb@FreeBSD.ORG Fri Apr 18 08:40:01 2014 Return-Path: Delivered-To: freebsd-usb@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3EADDD4D for ; Fri, 18 Apr 2014 08:40: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 2C70D14FA for ; Fri, 18 Apr 2014 08:40: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 s3I8e1ih059662 for ; Fri, 18 Apr 2014 08:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3I8e13X059661; Fri, 18 Apr 2014 08:40:01 GMT (envelope-from gnats) Date: Fri, 18 Apr 2014 08:40:01 GMT Message-Id: <201404180840.s3I8e13X059661@freefall.freebsd.org> To: freebsd-usb@FreeBSD.org Cc: From: dfilter@FreeBSD.ORG (dfilter service) Subject: Re: usb/188683: commit references a PR X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: dfilter service List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Apr 2014 08:40:01 -0000 The following reply was made to PR usb/188683; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/188683: commit references a PR Date: Fri, 18 Apr 2014 08:32:00 +0000 (UTC) Author: hselasky Date: Fri Apr 18 08:31:55 2014 New Revision: 264642 URL: http://svnweb.freebsd.org/changeset/base/264642 Log: Add support for specifying USB controller mode via FDT. Add FDT support to the DWC OTG kernel module. Submitted by: John Wehle PR: usb/188683 MFC after: 1 week Modified: head/sys/dev/usb/controller/dwc_otg.c head/sys/dev/usb/controller/dwc_otg_fdt.c head/sys/modules/usb/dwc_otg/Makefile Modified: head/sys/dev/usb/controller/dwc_otg.c ============================================================================== --- head/sys/dev/usb/controller/dwc_otg.c Fri Apr 18 07:50:25 2014 (r264641) +++ head/sys/dev/usb/controller/dwc_otg.c Fri Apr 18 08:31:55 2014 (r264642) @@ -2149,7 +2149,12 @@ dwc_otg_vbus_interrupt(struct dwc_otg_so { DPRINTFN(5, "vbus = %u\n", is_on); - if (is_on) { + /* + * If the USB host mode is forced, then assume VBUS is always + * present else rely on the input to this function: + */ + if ((is_on != 0) || (sc->sc_mode == DWC_MODE_HOST)) { + if (!sc->sc_flags.status_vbus) { sc->sc_flags.status_vbus = 1; @@ -3182,7 +3187,7 @@ dwc_otg_init(struct dwc_otg_softc *sc) 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 */ Modified: head/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- head/sys/dev/usb/controller/dwc_otg_fdt.c Fri Apr 18 07:50:25 2014 (r264641) +++ head/sys/dev/usb/controller/dwc_otg_fdt.c Fri Apr 18 08:31:55 2014 (r264642) @@ -91,6 +91,7 @@ static int dwc_otg_attach(device_t dev) { struct dwc_otg_super_softc *sc = device_get_softc(dev); + char usb_mode[24]; int err; int rid; @@ -99,6 +100,23 @@ dwc_otg_attach(device_t dev) sc->sc_otg.sc_bus.devices = sc->sc_otg.sc_devices; sc->sc_otg.sc_bus.devices_max = DWC_OTG_MAX_DEVICES; + /* get USB mode, if any */ + if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", + &usb_mode, sizeof(usb_mode)) > 0) { + + /* ensure proper zero termination */ + usb_mode[sizeof(usb_mode) - 1] = 0; + + if (strcasecmp(usb_mode, "host") == 0) + sc->sc_otg.sc_mode = DWC_MODE_HOST; + else if (strcasecmp(usb_mode, "peripheral") == 0) + sc->sc_otg.sc_mode = DWC_MODE_DEVICE; + else if (strcasecmp(usb_mode, "otg") != 0) { + device_printf(dev, "Invalid FDT dr_mode: %s\n", + usb_mode); + } + } + /* get all DMA memory */ if (usb_bus_mem_alloc_all(&sc->sc_otg.sc_bus, USB_GET_DMA_TAG(dev), NULL)) { Modified: head/sys/modules/usb/dwc_otg/Makefile ============================================================================== --- head/sys/modules/usb/dwc_otg/Makefile Fri Apr 18 07:50:25 2014 (r264641) +++ head/sys/modules/usb/dwc_otg/Makefile Fri Apr 18 08:31:55 2014 (r264642) @@ -31,8 +31,8 @@ S= ${.CURDIR}/../../.. KMOD= dwc_otg SRCS= bus_if.h device_if.h usb_if.h \ - opt_bus.h opt_usb.h \ - dwc_otg.c \ + opt_bus.h opt_usb.h ofw_bus_if.h \ + dwc_otg.c dwc_otg_fdt.c \ pci_if.h .if defined(HAS_ATMELARM) _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"