Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Oct 2012 05:42:43 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241082 - in head/sys: dev/usb dev/usb/controller mips/cavium/usb
Message-ID:  <201210010542.q915gh6H089388@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Oct  1 05:42:43 2012
New Revision: 241082
URL: http://svn.freebsd.org/changeset/base/241082

Log:
  Inherit USB mode from RootHUB port where the USB device is connected.
  Only RootHUB ports can be dual mode. Disallow OTG ports on external HUBs.
  This simplifies some checks in the USB controller drivers.
  
  MFC after:	1 week

Modified:
  head/sys/dev/usb/controller/at91dci.c
  head/sys/dev/usb/controller/atmegadci.c
  head/sys/dev/usb/controller/avr32dci.c
  head/sys/dev/usb/controller/ehci.c
  head/sys/dev/usb/controller/musb_otg.c
  head/sys/dev/usb/controller/ohci.c
  head/sys/dev/usb/controller/uhci.c
  head/sys/dev/usb/controller/uss820dci.c
  head/sys/dev/usb/controller/xhci.c
  head/sys/dev/usb/usb_hub.c
  head/sys/mips/cavium/usb/octusb.c

Modified: head/sys/dev/usb/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb/controller/at91dci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/at91dci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2277,10 +2277,6 @@ at91dci_ep_init(struct usb_device *udev,
 
 	if (udev->device_index != sc->sc_rt_addr) {
 
-		if (udev->flags.usb_mode != USB_MODE_DEVICE) {
-			/* not supported */
-			return;
-		}
 		if (udev->speed != USB_SPEED_FULL) {
 			/* not supported */
 			return;

Modified: head/sys/dev/usb/controller/atmegadci.c
==============================================================================
--- head/sys/dev/usb/controller/atmegadci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/atmegadci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2112,10 +2112,6 @@ atmegadci_ep_init(struct usb_device *ude
 
 	if (udev->device_index != sc->sc_rt_addr) {
 
-		if (udev->flags.usb_mode != USB_MODE_DEVICE) {
-			/* not supported */
-			return;
-		}
 		if (udev->speed != USB_SPEED_FULL) {
 			/* not supported */
 			return;

Modified: head/sys/dev/usb/controller/avr32dci.c
==============================================================================
--- head/sys/dev/usb/controller/avr32dci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/avr32dci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2056,10 +2056,6 @@ avr32dci_ep_init(struct usb_device *udev
 
 	if (udev->device_index != sc->sc_rt_addr) {
 
-		if (udev->flags.usb_mode != USB_MODE_DEVICE) {
-			/* not supported */
-			return;
-		}
 		if ((udev->speed != USB_SPEED_FULL) &&
 		    (udev->speed != USB_SPEED_HIGH)) {
 			/* not supported */

Modified: head/sys/dev/usb/controller/ehci.c
==============================================================================
--- head/sys/dev/usb/controller/ehci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/ehci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -3701,10 +3701,6 @@ ehci_ep_init(struct usb_device *udev, st
 	    edesc->bEndpointAddress, udev->flags.usb_mode,
 	    sc->sc_addr);
 
-	if (udev->flags.usb_mode != USB_MODE_HOST) {
-		/* not supported */
-		return;
-	}
 	if (udev->device_index != sc->sc_addr) {
 
 		if ((udev->speed != USB_SPEED_HIGH) &&

Modified: head/sys/dev/usb/controller/musb_otg.c
==============================================================================
--- head/sys/dev/usb/controller/musb_otg.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/musb_otg.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2748,10 +2748,6 @@ musbotg_ep_init(struct usb_device *udev,
 
 	if (udev->device_index != sc->sc_rt_addr) {
 
-		if (udev->flags.usb_mode != USB_MODE_DEVICE) {
-			/* not supported */
-			return;
-		}
 		if ((udev->speed != USB_SPEED_FULL) &&
 		    (udev->speed != USB_SPEED_HIGH)) {
 			/* not supported */

Modified: head/sys/dev/usb/controller/ohci.c
==============================================================================
--- head/sys/dev/usb/controller/ohci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/ohci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2315,6 +2315,7 @@ ohci_roothub_exec(struct usb_device *ude
 		}
 		v = OREAD4(sc, OHCI_RH_PORT_STATUS(index));
 		DPRINTFN(9, "port status=0x%04x\n", v);
+		v &= ~UPS_PORT_MODE_DEVICE;	/* force host mode */
 		USETW(sc->sc_hub_desc.ps.wPortStatus, v);
 		USETW(sc->sc_hub_desc.ps.wPortChange, v >> 16);
 		len = sizeof(sc->sc_hub_desc.ps);
@@ -2551,10 +2552,6 @@ ohci_ep_init(struct usb_device *udev, st
 	    edesc->bEndpointAddress, udev->flags.usb_mode,
 	    sc->sc_addr);
 
-	if (udev->flags.usb_mode != USB_MODE_HOST) {
-		/* not supported */
-		return;
-	}
 	if (udev->device_index != sc->sc_addr) {
 		switch (edesc->bmAttributes & UE_XFERTYPE) {
 		case UE_CONTROL:

Modified: head/sys/dev/usb/controller/uhci.c
==============================================================================
--- head/sys/dev/usb/controller/uhci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/uhci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -3030,10 +3030,6 @@ uhci_ep_init(struct usb_device *udev, st
 	    edesc->bEndpointAddress, udev->flags.usb_mode,
 	    sc->sc_addr);
 
-	if (udev->flags.usb_mode != USB_MODE_HOST) {
-		/* not supported */
-		return;
-	}
 	if (udev->device_index != sc->sc_addr) {
 		switch (edesc->bmAttributes & UE_XFERTYPE) {
 		case UE_CONTROL:

Modified: head/sys/dev/usb/controller/uss820dci.c
==============================================================================
--- head/sys/dev/usb/controller/uss820dci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/uss820dci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -2333,10 +2333,6 @@ uss820dci_ep_init(struct usb_device *ude
 
 	if (udev->device_index != sc->sc_rt_addr) {
 
-		if (udev->flags.usb_mode != USB_MODE_DEVICE) {
-			/* not supported */
-			return;
-		}
 		if (udev->speed != USB_SPEED_FULL) {
 			/* not supported */
 			return;

Modified: head/sys/dev/usb/controller/xhci.c
==============================================================================
--- head/sys/dev/usb/controller/xhci.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/controller/xhci.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -3712,10 +3712,6 @@ xhci_ep_init(struct usb_device *udev, st
 	DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n",
 	    ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode);
 
-	if (udev->flags.usb_mode != USB_MODE_HOST) {
-		/* not supported */
-		return;
-	}
 	if (udev->parent_hub == NULL) {
 		/* root HUB has special endpoint handling */
 		return;

Modified: head/sys/dev/usb/usb_hub.c
==============================================================================
--- head/sys/dev/usb/usb_hub.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/dev/usb/usb_hub.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -518,7 +518,10 @@ repeat:
 	 *
 	 * NOTE: This part is currently FreeBSD specific.
 	 */
-	if (sc->sc_st.port_status & UPS_PORT_MODE_DEVICE)
+	if (udev->parent_hub != NULL) {
+		/* inherit mode from the parent HUB */
+		mode = udev->parent_hub->flags.usb_mode;
+	} else if (sc->sc_st.port_status & UPS_PORT_MODE_DEVICE)
 		mode = USB_MODE_DEVICE;
 	else
 		mode = USB_MODE_HOST;

Modified: head/sys/mips/cavium/usb/octusb.c
==============================================================================
--- head/sys/mips/cavium/usb/octusb.c	Mon Oct  1 05:15:13 2012	(r241081)
+++ head/sys/mips/cavium/usb/octusb.c	Mon Oct  1 05:42:43 2012	(r241082)
@@ -1860,10 +1860,6 @@ octusb_ep_init(struct usb_device *udev, 
 	    ep, udev->address, edesc->bEndpointAddress,
 	    udev->flags.usb_mode, sc->sc_addr);
 
-	if (udev->flags.usb_mode != USB_MODE_HOST) {
-		/* not supported */
-		return;
-	}
 	if (udev->device_index != sc->sc_addr) {
 		switch (edesc->bmAttributes & UE_XFERTYPE) {
 		case UE_CONTROL:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210010542.q915gh6H089388>