From 391d3f18dcd9899b85b5cc9b5eef22031f3b297a Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 24 Sep 2012 16:34:13 +0000 Subject: [PATCH] DWC OTG host mode improvements: - Make HSIC selection dynamic. - Make LOW speed USB devices work through HIGH speed USB HUB. --- sys/dev/usb/controller/dwc_otg.c | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index c8f73a5dc09..59c42562b7e 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -101,12 +101,18 @@ __FBSDID("$FreeBSD$"); GINTMSK_HCHINTMSK | \ GINTSTS_PRTINT) -#define DWC_OTG_USE_HSIC 0 +static int dwc_otg_use_hsic; + +static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); + +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RD, + &dwc_otg_use_hsic, 0, "DWC OTG uses HSIC interface"); + +TUNABLE_INT("hw.usb.dwc_otg.use_hsic", &dwc_otg_use_hsic); #ifdef USB_DEBUG static int dwc_otg_debug; -static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RW, &dwc_otg_debug, 0, "DWC OTG debug level"); #endif @@ -701,6 +707,15 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) } } + /* treat NYET like NAK, if SPLIT transactions are used */ + if (hcint & HCINT_NYET) { + if (td->hcsplt != 0) { + DPRINTF("CH=%d NYET+SPLIT\n", td->channel); + hcint &= ~HCINT_NYET; + hcint |= HCINT_NAK; + } + } + /* channel must be disabled before we can complete the transfer */ if (hcint & (HCINT_ERRORS | HCINT_RETRY | @@ -1041,6 +1056,15 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) } } + /* treat NYET like NAK, if SPLIT transactions are used */ + if (hcint & HCINT_NYET) { + if (td->hcsplt != 0) { + DPRINTF("CH=%d NYET+SPLIT\n", td->channel); + hcint &= ~HCINT_NYET; + hcint |= HCINT_NAK; + } + } + /* channel must be disabled before we can complete the transfer */ if (hcint & (HCINT_ERRORS | HCINT_RETRY | @@ -1391,6 +1415,15 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) } } + /* treat NYET like NAK, if SPLIT transactions are used */ + if (hcint & HCINT_NYET) { + if (td->hcsplt != 0) { + DPRINTF("CH=%d NYET+SPLIT\n", td->channel); + hcint &= ~HCINT_NYET; + hcint |= HCINT_NAK; + } + } + /* channel must be disabled before we can complete the transfer */ if (hcint & (HCINT_ERRORS | HCINT_RETRY | @@ -2979,7 +3012,7 @@ dwc_otg_init(struct dwc_otg_softc *sc) } /* select HSIC or non-HSIC mode */ - if (DWC_OTG_USE_HSIC) { + if (dwc_otg_use_hsic) { DWC_OTG_WRITE_4(sc, DOTG_GUSBCFG, GUSBCFG_PHYIF | GUSBCFG_TRD_TIM_SET(5) | temp);