svn commit: r190735 - in head/sys/dev/usb: . controller

Andrew Thompson thompsa at FreeBSD.org
Sun Apr 5 11:20:54 PDT 2009


Author: thompsa
Date: Sun Apr  5 18:20:49 2009
New Revision: 190735
URL: http://svn.freebsd.org/changeset/base/190735

Log:
  MFp4 //depot/projects/usb at 159922
  
  Refactor how we interface with the root HUB. This cuts around 1200 lines of
  code totally and saves one thread per USB bus.
  
  Submitted by:	Hans Petter Selasky

Modified:
  head/sys/dev/usb/controller/at91dci.c
  head/sys/dev/usb/controller/at91dci.h
  head/sys/dev/usb/controller/atmegadci.c
  head/sys/dev/usb/controller/atmegadci.h
  head/sys/dev/usb/controller/ehci.c
  head/sys/dev/usb/controller/ehci.h
  head/sys/dev/usb/controller/musb_otg.c
  head/sys/dev/usb/controller/musb_otg.h
  head/sys/dev/usb/controller/ohci.c
  head/sys/dev/usb/controller/ohci.h
  head/sys/dev/usb/controller/uhci.c
  head/sys/dev/usb/controller/uhci.h
  head/sys/dev/usb/controller/usb_controller.c
  head/sys/dev/usb/controller/uss820dci.c
  head/sys/dev/usb/controller/uss820dci.h
  head/sys/dev/usb/usb_bus.h
  head/sys/dev/usb/usb_controller.h
  head/sys/dev/usb/usb_core.h
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_hub.c
  head/sys/dev/usb/usb_hub.h
  head/sys/dev/usb/usb_request.c
  head/sys/dev/usb/usb_sw_transfer.c
  head/sys/dev/usb/usb_sw_transfer.h
  head/sys/dev/usb/usb_transfer.c

Modified: head/sys/dev/usb/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb/controller/at91dci.c	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/at91dci.c	Sun Apr  5 18:20:49 2009	(r190735)
@@ -88,8 +88,6 @@ struct usb2_pipe_methods at91dci_device_
 struct usb2_pipe_methods at91dci_device_ctrl_methods;
 struct usb2_pipe_methods at91dci_device_intr_methods;
 struct usb2_pipe_methods at91dci_device_isoc_fs_methods;
-struct usb2_pipe_methods at91dci_root_ctrl_methods;
-struct usb2_pipe_methods at91dci_root_intr_methods;
 
 static at91dci_cmd_t at91dci_setup_rx;
 static at91dci_cmd_t at91dci_data_rx;
@@ -97,11 +95,8 @@ static at91dci_cmd_t at91dci_data_tx;
 static at91dci_cmd_t at91dci_data_tx_sync;
 static void	at91dci_device_done(struct usb2_xfer *, usb2_error_t);
 static void	at91dci_do_poll(struct usb2_bus *);
-static void	at91dci_root_ctrl_poll(struct at91dci_softc *);
 static void	at91dci_standard_done(struct usb2_xfer *);
-
-static usb2_sw_transfer_func_t at91dci_root_intr_done;
-static usb2_sw_transfer_func_t at91dci_root_ctrl_done;
+static void	at91dci_root_intr(struct at91dci_softc *sc);
 
 /*
  * NOTE: Some of the bits in the CSR register have inverse meaning so
@@ -256,10 +251,8 @@ at91dci_pull_down(struct at91dci_softc *
 }
 
 static void
-at91dci_wakeup_peer(struct usb2_xfer *xfer)
+at91dci_wakeup_peer(struct at91dci_softc *sc)
 {
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
 	if (!(sc->sc_flags.status_suspend)) {
 		return;
 	}
@@ -736,9 +729,7 @@ at91dci_vbus_interrupt(struct at91dci_so
 			sc->sc_flags.status_vbus = 1;
 
 			/* complete root HUB interrupt endpoint */
-
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &at91dci_root_intr_done);
+			at91dci_root_intr(sc);
 		}
 	} else {
 		if (sc->sc_flags.status_vbus) {
@@ -749,9 +740,7 @@ at91dci_vbus_interrupt(struct at91dci_so
 			sc->sc_flags.change_connect = 1;
 
 			/* complete root HUB interrupt endpoint */
-
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &at91dci_root_intr_done);
+			at91dci_root_intr(sc);
 		}
 	}
 	USB_BUS_UNLOCK(&sc->sc_bus);
@@ -828,9 +817,7 @@ at91dci_interrupt(struct at91dci_softc *
 			}
 		}
 		/* complete root HUB interrupt endpoint */
-
-		usb2_sw_transfer(&sc->sc_root_intr,
-		    &at91dci_root_intr_done);
+		at91dci_root_intr(sc);
 	}
 	/* check for any endpoint interrupts */
 
@@ -1070,31 +1057,17 @@ at91dci_start_standard_chain(struct usb2
 }
 
 static void
-at91dci_root_intr_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
+at91dci_root_intr(struct at91dci_softc *sc)
 {
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
 	DPRINTFN(9, "\n");
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_PRE_DATA) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			at91dci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
-	/* setup buffer */
-	std->ptr = sc->sc_hub_idata;
-	std->len = sizeof(sc->sc_hub_idata);
-
 	/* set port bit */
 	sc->sc_hub_idata[0] = 0x02;	/* we only have one port */
 
-done:
-	return;
+	uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata,
+	    sizeof(sc->sc_hub_idata));
 }
 
 static usb2_error_t
@@ -1488,7 +1461,6 @@ at91dci_do_poll(struct usb2_bus *bus)
 
 	USB_BUS_LOCK(&sc->sc_bus);
 	at91dci_interrupt_poll(sc);
-	at91dci_root_ctrl_poll(sc);
 	USB_BUS_UNLOCK(&sc->sc_bus);
 }
 
@@ -1696,31 +1668,9 @@ struct usb2_pipe_methods at91dci_device_
 /*------------------------------------------------------------------------*
  * at91dci root control support
  *------------------------------------------------------------------------*
- * simulate a hardware HUB by handling
- * all the necessary requests
+ * Simulate a hardware HUB by handling all the necessary requests.
  *------------------------------------------------------------------------*/
 
-static void
-at91dci_root_ctrl_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-at91dci_root_ctrl_close(struct usb2_xfer *xfer)
-{
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_ctrl.xfer == xfer) {
-		sc->sc_root_ctrl.xfer = NULL;
-	}
-	at91dci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
-/*
- * USB descriptors for the virtual Root HUB:
- */
-
 static const struct usb2_device_descriptor at91dci_devd = {
 	.bLength = sizeof(struct usb2_device_descriptor),
 	.bDescriptorType = UDESC_DEVICE,
@@ -1765,7 +1715,6 @@ static const struct at91dci_config_desc 
 		.bInterfaceSubClass = UISUBCLASS_HUB,
 		.bInterfaceProtocol = UIPROTO_HSHUBSTT,
 	},
-
 	.endpd = {
 		.bLength = sizeof(struct usb2_endpoint_descriptor),
 		.bDescriptorType = UDESC_ENDPOINT,
@@ -1805,44 +1754,15 @@ USB_MAKE_STRING_DESC(STRING_VENDOR, at91
 USB_MAKE_STRING_DESC(STRING_PRODUCT, at91dci_product);
 
 static void
-at91dci_root_ctrl_enter(struct usb2_xfer *xfer)
+at91dci_roothub_exec(struct usb2_bus *bus)
 {
-	return;
-}
-
-static void
-at91dci_root_ctrl_start(struct usb2_xfer *xfer)
-{
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
-	sc->sc_root_ctrl.xfer = xfer;
-
-	usb2_bus_roothub_exec(xfer->xroot->bus);
-}
-
-static void
-at91dci_root_ctrl_task(struct usb2_bus *bus)
-{
-	at91dci_root_ctrl_poll(AT9100_DCI_BUS2SC(bus));
-}
-
-static void
-at91dci_root_ctrl_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
-{
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
+	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(bus);
+	struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
 	uint16_t value;
 	uint16_t index;
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_SETUP) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			at91dci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
 	/* buffer reset */
 	std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0);
 	std->len = 0;
@@ -2101,7 +2021,7 @@ tr_handle_clear_port_feature:
 
 	switch (value) {
 	case UHF_PORT_SUSPEND:
-		at91dci_wakeup_peer(xfer);
+		at91dci_wakeup_peer(sc);
 		break;
 
 	case UHF_PORT_ENABLE:
@@ -2225,67 +2145,6 @@ done:
 }
 
 static void
-at91dci_root_ctrl_poll(struct at91dci_softc *sc)
-{
-	usb2_sw_transfer(&sc->sc_root_ctrl,
-	    &at91dci_root_ctrl_done);
-}
-
-struct usb2_pipe_methods at91dci_root_ctrl_methods =
-{
-	.open = at91dci_root_ctrl_open,
-	.close = at91dci_root_ctrl_close,
-	.enter = at91dci_root_ctrl_enter,
-	.start = at91dci_root_ctrl_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 0,
-};
-
-/*------------------------------------------------------------------------*
- * at91dci root interrupt support
- *------------------------------------------------------------------------*/
-static void
-at91dci_root_intr_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-at91dci_root_intr_close(struct usb2_xfer *xfer)
-{
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_intr.xfer == xfer) {
-		sc->sc_root_intr.xfer = NULL;
-	}
-	at91dci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
-static void
-at91dci_root_intr_enter(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-at91dci_root_intr_start(struct usb2_xfer *xfer)
-{
-	struct at91dci_softc *sc = AT9100_DCI_BUS2SC(xfer->xroot->bus);
-
-	sc->sc_root_intr.xfer = xfer;
-}
-
-struct usb2_pipe_methods at91dci_root_intr_methods =
-{
-	.open = at91dci_root_intr_open,
-	.close = at91dci_root_intr_close,
-	.enter = at91dci_root_intr_enter,
-	.start = at91dci_root_intr_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 1,
-};
-
-static void
 at91dci_xfer_setup(struct usb2_setup_params *parm)
 {
 	const struct usb2_hw_ep_profile *pf;
@@ -2411,24 +2270,7 @@ at91dci_pipe_init(struct usb2_device *ud
 	    edesc->bEndpointAddress, udev->flags.usb2_mode,
 	    sc->sc_rt_addr);
 
-	if (udev->device_index == sc->sc_rt_addr) {
-
-		if (udev->flags.usb2_mode != USB_MODE_HOST) {
-			/* not supported */
-			return;
-		}
-		switch (edesc->bEndpointAddress) {
-		case USB_CONTROL_ENDPOINT:
-			pipe->methods = &at91dci_root_ctrl_methods;
-			break;
-		case UE_DIR_IN | AT9100_DCI_INTR_ENDPT:
-			pipe->methods = &at91dci_root_intr_methods;
-			break;
-		default:
-			/* do nothing */
-			break;
-		}
-	} else {
+	if (udev->device_index != sc->sc_rt_addr) {
 
 		if (udev->flags.usb2_mode != USB_MODE_DEVICE) {
 			/* not supported */
@@ -2466,5 +2308,5 @@ struct usb2_bus_methods at91dci_bus_meth
 	.get_hw_ep_profile = &at91dci_get_hw_ep_profile,
 	.set_stall = &at91dci_set_stall,
 	.clear_stall = &at91dci_clear_stall,
-	.roothub_exec = &at91dci_root_ctrl_task,
+	.roothub_exec = &at91dci_roothub_exec,
 };

Modified: head/sys/dev/usb/controller/at91dci.h
==============================================================================
--- head/sys/dev/usb/controller/at91dci.h	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/at91dci.h	Sun Apr  5 18:20:49 2009	(r190735)
@@ -204,8 +204,6 @@ struct at91dci_softc {
 	struct usb2_bus sc_bus;
 	union at91dci_hub_temp sc_hub_temp;
 	LIST_HEAD(, usb2_xfer) sc_interrupt_list_head;
-	struct usb2_sw_transfer sc_root_ctrl;
-	struct usb2_sw_transfer sc_root_intr;
 
 	struct usb2_device *sc_devices[AT91_MAX_DEVICES];
 	struct resource *sc_io_res;

Modified: head/sys/dev/usb/controller/atmegadci.c
==============================================================================
--- head/sys/dev/usb/controller/atmegadci.c	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/atmegadci.c	Sun Apr  5 18:20:49 2009	(r190735)
@@ -81,8 +81,6 @@ struct usb2_pipe_methods atmegadci_devic
 struct usb2_pipe_methods atmegadci_device_ctrl_methods;
 struct usb2_pipe_methods atmegadci_device_intr_methods;
 struct usb2_pipe_methods atmegadci_device_isoc_fs_methods;
-struct usb2_pipe_methods atmegadci_root_ctrl_methods;
-struct usb2_pipe_methods atmegadci_root_intr_methods;
 
 static atmegadci_cmd_t atmegadci_setup_rx;
 static atmegadci_cmd_t atmegadci_data_rx;
@@ -90,11 +88,8 @@ static atmegadci_cmd_t atmegadci_data_tx
 static atmegadci_cmd_t atmegadci_data_tx_sync;
 static void atmegadci_device_done(struct usb2_xfer *, usb2_error_t);
 static void atmegadci_do_poll(struct usb2_bus *);
-static void atmegadci_root_ctrl_poll(struct atmegadci_softc *);
 static void atmegadci_standard_done(struct usb2_xfer *);
-
-static usb2_sw_transfer_func_t atmegadci_root_intr_done;
-static usb2_sw_transfer_func_t atmegadci_root_ctrl_done;
+static void atmegadci_root_intr(struct atmegadci_softc *sc);
 
 /*
  * Here is a list of what the chip supports:
@@ -201,9 +196,8 @@ atmegadci_pull_down(struct atmegadci_sof
 }
 
 static void
-atmegadci_wakeup_peer(struct usb2_xfer *xfer)
+atmegadci_wakeup_peer(struct atmegadci_softc *sc)
 {
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
 	uint8_t temp;
 
 	if (!sc->sc_flags.status_suspend) {
@@ -625,8 +619,7 @@ atmegadci_vbus_interrupt(struct atmegadc
 
 			/* complete root HUB interrupt endpoint */
 
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &atmegadci_root_intr_done);
+			atmegadci_root_intr(sc);
 		}
 	} else {
 		if (sc->sc_flags.status_vbus) {
@@ -638,8 +631,7 @@ atmegadci_vbus_interrupt(struct atmegadc
 
 			/* complete root HUB interrupt endpoint */
 
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &atmegadci_root_intr_done);
+			atmegadci_root_intr(sc);
 		}
 	}
 }
@@ -676,8 +668,7 @@ atmegadci_interrupt(struct atmegadci_sof
 		    ATMEGA_UDINT_EORSTE);
 
 		/* complete root HUB interrupt endpoint */
-		usb2_sw_transfer(&sc->sc_root_intr,
-		    &atmegadci_root_intr_done);
+		atmegadci_root_intr(sc);
 	}
 	/*
 	 * If resume and suspend is set at the same time we interpret
@@ -699,8 +690,7 @@ atmegadci_interrupt(struct atmegadci_sof
 			    ATMEGA_UDINT_EORSTE);
 
 			/* complete root HUB interrupt endpoint */
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &atmegadci_root_intr_done);
+			atmegadci_root_intr(sc);
 		}
 	} else if (status & ATMEGA_UDINT_SUSPI) {
 
@@ -717,8 +707,7 @@ atmegadci_interrupt(struct atmegadci_sof
 			    ATMEGA_UDINT_EORSTE);
 
 			/* complete root HUB interrupt endpoint */
-			usb2_sw_transfer(&sc->sc_root_intr,
-			    &atmegadci_root_intr_done);
+			atmegadci_root_intr(sc);
 		}
 	}
 	/* check VBUS */
@@ -953,32 +942,18 @@ atmegadci_start_standard_chain(struct us
 }
 
 static void
-atmegadci_root_intr_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
+atmegadci_root_intr(struct atmegadci_softc *sc)
 {
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
-
 	DPRINTFN(9, "\n");
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_PRE_DATA) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			atmegadci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
-	/* setup buffer */
-	std->ptr = sc->sc_hub_idata;
-	std->len = sizeof(sc->sc_hub_idata);
-
 	/* set port bit */
 	sc->sc_hub_idata[0] = 0x02;	/* we only have one port */
 
-done:
-	return;
-}
+	uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata,
+	    sizeof(sc->sc_hub_idata));
+ }
 
 static usb2_error_t
 atmegadci_standard_done_sub(struct usb2_xfer *xfer)
@@ -1363,7 +1338,6 @@ atmegadci_do_poll(struct usb2_bus *bus)
 
 	USB_BUS_LOCK(&sc->sc_bus);
 	atmegadci_interrupt_poll(sc);
-	atmegadci_root_ctrl_poll(sc);
 	USB_BUS_UNLOCK(&sc->sc_bus);
 }
 
@@ -1575,27 +1549,9 @@ struct usb2_pipe_methods atmegadci_devic
 /*------------------------------------------------------------------------*
  * at91dci root control support
  *------------------------------------------------------------------------*
- * simulate a hardware HUB by handling
- * all the necessary requests
+ * Simulate a hardware HUB by handling all the necessary requests.
  *------------------------------------------------------------------------*/
 
-static void
-atmegadci_root_ctrl_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-atmegadci_root_ctrl_close(struct usb2_xfer *xfer)
-{
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_ctrl.xfer == xfer) {
-		sc->sc_root_ctrl.xfer = NULL;
-	}
-	atmegadci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
 /*
  * USB descriptors for the virtual Root HUB:
  */
@@ -1644,7 +1600,6 @@ static const struct atmegadci_config_des
 		.bInterfaceSubClass = UISUBCLASS_HUB,
 		.bInterfaceProtocol = UIPROTO_HSHUBSTT,
 	},
-
 	.endpd = {
 		.bLength = sizeof(struct usb2_endpoint_descriptor),
 		.bDescriptorType = UDESC_ENDPOINT,
@@ -1684,45 +1639,16 @@ USB_MAKE_STRING_DESC(STRING_VENDOR, atme
 USB_MAKE_STRING_DESC(STRING_PRODUCT, atmegadci_product);
 
 static void
-atmegadci_root_ctrl_enter(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-atmegadci_root_ctrl_start(struct usb2_xfer *xfer)
-{
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
-
-	sc->sc_root_ctrl.xfer = xfer;
-
-	usb2_bus_roothub_exec(xfer->xroot->bus);
-}
-
-static void
-atmegadci_root_ctrl_task(struct usb2_bus *bus)
-{
-	atmegadci_root_ctrl_poll(ATMEGA_BUS2SC(bus));
-}
-
-static void
-atmegadci_root_ctrl_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
+atmegadci_roothub_exec(struct usb2_bus *bus)
 {
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
+	struct atmegadci_softc *sc = ATMEGA_BUS2SC(bus);
+	struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
 	uint16_t value;
 	uint16_t index;
 	uint8_t temp;
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_SETUP) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			atmegadci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
 	/* buffer reset */
 	std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0);
 	std->len = 0;
@@ -1981,7 +1907,7 @@ tr_handle_clear_port_feature:
 
 	switch (value) {
 	case UHF_PORT_SUSPEND:
-		atmegadci_wakeup_peer(xfer);
+		atmegadci_wakeup_peer(sc);
 		break;
 
 	case UHF_PORT_ENABLE:
@@ -2130,67 +2056,6 @@ done:
 }
 
 static void
-atmegadci_root_ctrl_poll(struct atmegadci_softc *sc)
-{
-	usb2_sw_transfer(&sc->sc_root_ctrl,
-	    &atmegadci_root_ctrl_done);
-}
-
-struct usb2_pipe_methods atmegadci_root_ctrl_methods =
-{
-	.open = atmegadci_root_ctrl_open,
-	.close = atmegadci_root_ctrl_close,
-	.enter = atmegadci_root_ctrl_enter,
-	.start = atmegadci_root_ctrl_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 0,
-};
-
-/*------------------------------------------------------------------------*
- * at91dci root interrupt support
- *------------------------------------------------------------------------*/
-static void
-atmegadci_root_intr_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-atmegadci_root_intr_close(struct usb2_xfer *xfer)
-{
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_intr.xfer == xfer) {
-		sc->sc_root_intr.xfer = NULL;
-	}
-	atmegadci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
-static void
-atmegadci_root_intr_enter(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-atmegadci_root_intr_start(struct usb2_xfer *xfer)
-{
-	struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus);
-
-	sc->sc_root_intr.xfer = xfer;
-}
-
-struct usb2_pipe_methods atmegadci_root_intr_methods =
-{
-	.open = atmegadci_root_intr_open,
-	.close = atmegadci_root_intr_close,
-	.enter = atmegadci_root_intr_enter,
-	.start = atmegadci_root_intr_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 1,
-};
-
-static void
 atmegadci_xfer_setup(struct usb2_setup_params *parm)
 {
 	const struct usb2_hw_ep_profile *pf;
@@ -2313,24 +2178,7 @@ atmegadci_pipe_init(struct usb2_device *
 	    edesc->bEndpointAddress, udev->flags.usb2_mode,
 	    sc->sc_rt_addr, udev->device_index);
 
-	if (udev->device_index == sc->sc_rt_addr) {
-
-		if (udev->flags.usb2_mode != USB_MODE_HOST) {
-			/* not supported */
-			return;
-		}
-		switch (edesc->bEndpointAddress) {
-		case USB_CONTROL_ENDPOINT:
-			pipe->methods = &atmegadci_root_ctrl_methods;
-			break;
-		case UE_DIR_IN | ATMEGA_INTR_ENDPT:
-			pipe->methods = &atmegadci_root_intr_methods;
-			break;
-		default:
-			/* do nothing */
-			break;
-		}
-	} else {
+	if (udev->device_index != sc->sc_rt_addr) {
 
 		if (udev->flags.usb2_mode != USB_MODE_DEVICE) {
 			/* not supported */
@@ -2368,5 +2216,5 @@ struct usb2_bus_methods atmegadci_bus_me
 	.get_hw_ep_profile = &atmegadci_get_hw_ep_profile,
 	.set_stall = &atmegadci_set_stall,
 	.clear_stall = &atmegadci_clear_stall,
-	.roothub_exec = &atmegadci_root_ctrl_task,
+	.roothub_exec = &atmegadci_roothub_exec,
 };

Modified: head/sys/dev/usb/controller/atmegadci.h
==============================================================================
--- head/sys/dev/usb/controller/atmegadci.h	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/atmegadci.h	Sun Apr  5 18:20:49 2009	(r190735)
@@ -34,10 +34,6 @@
 
 #define	ATMEGA_MAX_DEVICES (USB_MIN_DEVICES + 1)
 
-#ifndef ATMEGA_HAVE_BUS_SPACE
-#define	ATMEGA_HAVE_BUS_SPACE 1
-#endif
-
 #define	ATMEGA_UEINT 0xF4
 #define	ATMEGA_UEINT_MASK(n) (1 << (n))	/* endpoint interrupt mask */
 
@@ -241,8 +237,6 @@ struct atmegadci_softc {
 	struct usb2_bus sc_bus;
 	union atmegadci_hub_temp sc_hub_temp;
 	LIST_HEAD(, usb2_xfer) sc_interrupt_list_head;
-	struct usb2_sw_transfer sc_root_ctrl;
-	struct usb2_sw_transfer sc_root_intr;
 
 	/* must be set by by the bus interface layer */
 	atmegadci_clocks_t *sc_clocks_on;
@@ -251,11 +245,10 @@ struct atmegadci_softc {
 	struct usb2_device *sc_devices[ATMEGA_MAX_DEVICES];
 	struct resource *sc_irq_res;
 	void   *sc_intr_hdl;
-#if (ATMEGA_HAVE_BUS_SPACE != 0)
 	struct resource *sc_io_res;
 	bus_space_tag_t sc_io_tag;
 	bus_space_handle_t sc_io_hdl;
-#endif
+
 	uint8_t	sc_rt_addr;		/* root hub address */
 	uint8_t	sc_dv_addr;		/* device address */
 	uint8_t	sc_conf;		/* root hub config */

Modified: head/sys/dev/usb/controller/ehci.c
==============================================================================
--- head/sys/dev/usb/controller/ehci.c	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/ehci.c	Sun Apr  5 18:20:49 2009	(r190735)
@@ -93,17 +93,12 @@ extern struct usb2_pipe_methods ehci_dev
 extern struct usb2_pipe_methods ehci_device_intr_methods;
 extern struct usb2_pipe_methods ehci_device_isoc_fs_methods;
 extern struct usb2_pipe_methods ehci_device_isoc_hs_methods;
-extern struct usb2_pipe_methods ehci_root_ctrl_methods;
-extern struct usb2_pipe_methods ehci_root_intr_methods;
 
 static void ehci_do_poll(struct usb2_bus *bus);
-static void ehci_root_ctrl_poll(ehci_softc_t *sc);
 static void ehci_device_done(struct usb2_xfer *xfer, usb2_error_t error);
 static uint8_t ehci_check_transfer(struct usb2_xfer *xfer);
 static void ehci_timeout(void *arg);
-
-static usb2_sw_transfer_func_t ehci_root_intr_done;
-static usb2_sw_transfer_func_t ehci_root_ctrl_done;
+static void ehci_root_intr(ehci_softc_t *sc);
 
 struct ehci_std_temp {
 	ehci_softc_t *sc;
@@ -1415,8 +1410,7 @@ ehci_pcd_enable(ehci_softc_t *sc)
 	/* acknowledge any PCD interrupt */
 	EOWRITE4(sc, EHCI_USBSTS, EHCI_STS_PCD);
 
-	usb2_sw_transfer(&sc->sc_root_intr,
-	    &ehci_root_intr_done);
+	ehci_root_intr(sc);
 }
 
 static void
@@ -1486,8 +1480,7 @@ ehci_interrupt(ehci_softc_t *sc)
 		sc->sc_eintrs &= ~EHCI_STS_PCD;
 		EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
 
-		usb2_sw_transfer(&sc->sc_root_intr,
-		    &ehci_root_intr_done);
+		ehci_root_intr(sc);
 
 		/* do not allow RHSC interrupts > 1 per second */
 		usb2_callout_reset(&sc->sc_tmo_pcd, hz,
@@ -1531,7 +1524,6 @@ ehci_do_poll(struct usb2_bus *bus)
 
 	USB_BUS_LOCK(&sc->sc_bus);
 	ehci_interrupt_poll(sc);
-	ehci_root_ctrl_poll(sc);
 	USB_BUS_UNLOCK(&sc->sc_bus);
 }
 
@@ -1979,28 +1971,15 @@ ehci_setup_standard_chain(struct usb2_xf
 }
 
 static void
-ehci_root_intr_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
+ehci_root_intr(ehci_softc_t *sc)
 {
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
 	uint16_t i;
 	uint16_t m;
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_PRE_DATA) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			ehci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
-	/* setup buffer */
-	std->ptr = sc->sc_hub_idata;
-	std->len = sizeof(sc->sc_hub_idata);
-
 	/* clear any old interrupt data */
-	bzero(sc->sc_hub_idata, sizeof(sc->sc_hub_idata));
+	memset(sc->sc_hub_idata, 0, sizeof(sc->sc_hub_idata));
 
 	/* set bits */
 	m = (sc->sc_noport + 1);
@@ -2014,8 +1993,8 @@ ehci_root_intr_done(struct usb2_xfer *xf
 			DPRINTF("port %d changed\n", i);
 		}
 	}
-done:
-	return;
+	uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata,
+	    sizeof(sc->sc_hub_idata));
 }
 
 static void
@@ -2932,31 +2911,9 @@ struct usb2_pipe_methods ehci_device_iso
 /*------------------------------------------------------------------------*
  * ehci root control support
  *------------------------------------------------------------------------*
- * simulate a hardware hub by handling
- * all the necessary requests
+ * Simulate a hardware hub by handling all the necessary requests.
  *------------------------------------------------------------------------*/
 
-static void
-ehci_root_ctrl_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-ehci_root_ctrl_close(struct usb2_xfer *xfer)
-{
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_ctrl.xfer == xfer) {
-		sc->sc_root_ctrl.xfer = NULL;
-	}
-	ehci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
-/* data structures and routines
- * to emulate the root hub:
- */
-
 static const
 struct usb2_device_descriptor ehci_devd =
 {
@@ -2997,7 +2954,6 @@ static const struct ehci_config_desc ehc
 		.bmAttributes = UC_SELF_POWERED,
 		.bMaxPower = 0		/* max power */
 	},
-
 	.ifcd = {
 		.bLength = sizeof(struct usb2_interface_descriptor),
 		.bDescriptorType = UDESC_INTERFACE,
@@ -3007,7 +2963,6 @@ static const struct ehci_config_desc ehc
 		.bInterfaceProtocol = UIPROTO_HSHUBSTT,
 		0
 	},
-
 	.endpd = {
 		.bLength = sizeof(struct usb2_endpoint_descriptor),
 		.bDescriptorType = UDESC_ENDPOINT,
@@ -3044,34 +2999,10 @@ ehci_disown(ehci_softc_t *sc, uint16_t i
 }
 
 static void
-ehci_root_ctrl_enter(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-ehci_root_ctrl_start(struct usb2_xfer *xfer)
-{
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
-
-	DPRINTF("\n");
-
-	sc->sc_root_ctrl.xfer = xfer;
-
-	usb2_bus_roothub_exec(xfer->xroot->bus);
-}
-
-static void
-ehci_root_ctrl_task(struct usb2_bus *bus)
-{
-	ehci_root_ctrl_poll(EHCI_BUS2SC(bus));
-}
-
-static void
-ehci_root_ctrl_done(struct usb2_xfer *xfer,
-    struct usb2_sw_transfer *std)
+ehci_roothub_exec(struct usb2_bus *bus)
 {
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
+	ehci_softc_t *sc = EHCI_BUS2SC(bus);
+	struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
 	char *ptr;
 	uint32_t port;
 	uint32_t v;
@@ -3082,13 +3013,6 @@ ehci_root_ctrl_done(struct usb2_xfer *xf
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
 
-	if (std->state != USB_SW_TR_SETUP) {
-		if (std->state == USB_SW_TR_PRE_CALLBACK) {
-			/* transfer transferred */
-			ehci_device_done(xfer, std->err);
-		}
-		goto done;
-	}
 	/* buffer reset */
 	std->ptr = sc->sc_hub_desc.temp;
 	std->len = 0;
@@ -3462,67 +3386,6 @@ done:
 }
 
 static void
-ehci_root_ctrl_poll(ehci_softc_t *sc)
-{
-	usb2_sw_transfer(&sc->sc_root_ctrl,
-	    &ehci_root_ctrl_done);
-}
-
-struct usb2_pipe_methods ehci_root_ctrl_methods =
-{
-	.open = ehci_root_ctrl_open,
-	.close = ehci_root_ctrl_close,
-	.enter = ehci_root_ctrl_enter,
-	.start = ehci_root_ctrl_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 0,
-};
-
-/*------------------------------------------------------------------------*
- * ehci root interrupt support
- *------------------------------------------------------------------------*/
-static void
-ehci_root_intr_open(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-ehci_root_intr_close(struct usb2_xfer *xfer)
-{
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
-
-	if (sc->sc_root_intr.xfer == xfer) {
-		sc->sc_root_intr.xfer = NULL;
-	}
-	ehci_device_done(xfer, USB_ERR_CANCELLED);
-}
-
-static void
-ehci_root_intr_enter(struct usb2_xfer *xfer)
-{
-	return;
-}
-
-static void
-ehci_root_intr_start(struct usb2_xfer *xfer)
-{
-	ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus);
-
-	sc->sc_root_intr.xfer = xfer;
-}
-
-struct usb2_pipe_methods ehci_root_intr_methods =
-{
-	.open = ehci_root_intr_open,
-	.close = ehci_root_intr_close,
-	.enter = ehci_root_intr_enter,
-	.start = ehci_root_intr_start,
-	.enter_is_cancelable = 1,
-	.start_is_cancelable = 1,
-};
-
-static void
 ehci_xfer_setup(struct usb2_setup_params *parm)
 {
 	struct usb2_page_search page_info;
@@ -3794,19 +3657,8 @@ ehci_pipe_init(struct usb2_device *udev,
 		/* not supported */
 		return;
 	}
-	if (udev->device_index == sc->sc_addr) {
-		switch (edesc->bEndpointAddress) {
-		case USB_CONTROL_ENDPOINT:
-			pipe->methods = &ehci_root_ctrl_methods;
-			break;
-		case UE_DIR_IN | EHCI_INTR_ENDPT:
-			pipe->methods = &ehci_root_intr_methods;
-			break;
-		default:
-			/* do nothing */
-			break;
-		}
-	} else {
+	if (udev->device_index != sc->sc_addr) {
+
 		if ((udev->speed != USB_SPEED_HIGH) &&
 		    ((udev->hs_hub_addr == 0) ||
 		    (udev->hs_port_no == 0) ||
@@ -3964,5 +3816,5 @@ struct usb2_bus_methods ehci_bus_methods
 	.device_resume = ehci_device_resume,
 	.device_suspend = ehci_device_suspend,
 	.set_hw_power = ehci_set_hw_power,
-	.roothub_exec = ehci_root_ctrl_task,
+	.roothub_exec = ehci_roothub_exec,
 };

Modified: head/sys/dev/usb/controller/ehci.h
==============================================================================
--- head/sys/dev/usb/controller/ehci.h	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/ehci.h	Sun Apr  5 18:20:49 2009	(r190735)
@@ -457,8 +457,6 @@ typedef struct ehci_softc {
 	struct usb2_bus sc_bus;		/* base device */
 	struct usb2_callout sc_tmo_pcd;
 	union ehci_hub_desc sc_hub_desc;
-	struct usb2_sw_transfer sc_root_ctrl;
-	struct usb2_sw_transfer sc_root_intr;
 
 	struct usb2_device *sc_devices[EHCI_MAX_DEVICES];
 	struct resource *sc_io_res;

Modified: head/sys/dev/usb/controller/musb_otg.c
==============================================================================
--- head/sys/dev/usb/controller/musb_otg.c	Sun Apr  5 18:20:38 2009	(r190734)
+++ head/sys/dev/usb/controller/musb_otg.c	Sun Apr  5 18:20:49 2009	(r190735)
@@ -80,8 +80,6 @@ struct usb2_pipe_methods musbotg_device_
 struct usb2_pipe_methods musbotg_device_ctrl_methods;
 struct usb2_pipe_methods musbotg_device_intr_methods;
 struct usb2_pipe_methods musbotg_device_isoc_methods;
-struct usb2_pipe_methods musbotg_root_ctrl_methods;
-struct usb2_pipe_methods musbotg_root_intr_methods;
 
 static musbotg_cmd_t musbotg_setup_rx;
 static musbotg_cmd_t musbotg_setup_data_rx;
@@ -91,12 +89,9 @@ static musbotg_cmd_t musbotg_data_rx;
 static musbotg_cmd_t musbotg_data_tx;
 static void	musbotg_device_done(struct usb2_xfer *, usb2_error_t);
 static void	musbotg_do_poll(struct usb2_bus *);
-static void	musbotg_root_ctrl_poll(struct musbotg_softc *);
 static void	musbotg_standard_done(struct usb2_xfer *);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list