From cfed2e639ec4efd032b1d6d4fd8e9441f8241d58 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Tue, 10 Jan 2017 03:53:38 +0000 Subject: [PATCH] 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). --- sys/dev/usb/controller/ehci_imx.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/ehci_imx.c b/sys/dev/usb/controller/ehci_imx.c index 07f73105f9a..df4d202c38e 100644 --- a/sys/dev/usb/controller/ehci_imx.c +++ b/sys/dev/usb/controller/ehci_imx.c @@ -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",