From owner-svn-src-head@freebsd.org Tue Jan 10 03:53:39 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C4E7CA89EF; Tue, 10 Jan 2017 03:53:39 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 494ED1DC5; Tue, 10 Jan 2017 03:53:39 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0A3rcr5058378; Tue, 10 Jan 2017 03:53:38 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0A3rcP3058377; Tue, 10 Jan 2017 03:53:38 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201701100353.v0A3rcP3058377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 10 Jan 2017 03:53:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311850 - head/sys/dev/usb/controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2017 03:53:39 -0000 Author: ian Date: Tue Jan 10 03:53:38 2017 New Revision: 311850 URL: https://svnweb.freebsd.org/changeset/base/311850 Log: Use the post-reset hook to force the controller to host mode. This will make both usb ports work on imx6 systems (the OTG port of course will only work in host mode). Modified: head/sys/dev/usb/controller/ehci_imx.c Modified: head/sys/dev/usb/controller/ehci_imx.c ============================================================================== --- head/sys/dev/usb/controller/ehci_imx.c Tue Jan 10 03:23:22 2017 (r311849) +++ head/sys/dev/usb/controller/ehci_imx.c Tue Jan 10 03:53:38 2017 (r311850) @@ -157,6 +157,18 @@ struct imx_ehci_softc { struct resource *ehci_irq_res; /* EHCI core IRQ. */ }; +static void +imx_ehci_post_reset(struct ehci_softc *ehci_softc) +{ + uint32_t usbmode; + + /* Force HOST mode */ + usbmode = EOREAD4(ehci_softc, EHCI_USBMODE_NOLPM); + usbmode &= ~EHCI_UM_CM; + usbmode |= EHCI_UM_CM_HOST; + EOWRITE4(ehci_softc, EHCI_USBMODE_NOLPM, usbmode); +} + static int imx_ehci_probe(device_t dev) { @@ -282,8 +294,13 @@ imx_ehci_attach(device_t dev) esc->sc_id_vendor = USB_VENDOR_FREESCALE; strlcpy(esc->sc_vendor, "Freescale", sizeof(esc->sc_vendor)); - /* Set flags that affect ehci_init() behavior. */ - esc->sc_flags |= EHCI_SCFLG_DONTRESET | EHCI_SCFLG_NORESTERM; + /* + * Set flags that affect ehci_init() behavior, and hook our post-reset + * code into the standard controller code. + */ + esc->sc_flags |= EHCI_SCFLG_NORESTERM; + esc->sc_vendor_post_reset = imx_ehci_post_reset; + err = ehci_init(esc); if (err != 0) { device_printf(dev, "USB init failed, usb_err_t=%d\n",