PERFORCE change 159922 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Fri Mar 27 13:16:02 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=159922
Change 159922 by hselasky at hselasky_laptop001 on 2009/03/27 20:15:38
USB core + USB controller:
- refactor how we interface with the
root HUB. This cuts around 1200 lines of
code totally and saves one thread per USB bus.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/at91dci.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/at91dci.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#15 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/ehci.c#12 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/ehci.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/musb_otg.c#9 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/musb_otg.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/ohci.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/ohci.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/uhci.c#8 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/uhci.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/usb_controller.c#10 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/uss820dci.c#10 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/uss820dci.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_bus.h#6 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_controller.h#4 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_core.h#10 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_hub.c#10 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_hub.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_request.c#9 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_sw_transfer.c#5 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_sw_transfer.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#137 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/at91dci.c#11 (text+ko) ====
@@ -88,8 +88,6 @@
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_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 @@
}
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 @@
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 @@
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 @@
}
}
/* 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 @@
}
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 @@
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 @@
/*------------------------------------------------------------------------*
* 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 @@
.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_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 @@
switch (value) {
case UHF_PORT_SUSPEND:
- at91dci_wakeup_peer(xfer);
+ at91dci_wakeup_peer(sc);
break;
case UHF_PORT_ENABLE:
@@ -2225,67 +2145,6 @@
}
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,25 +2270,8 @@
edesc->bEndpointAddress, udev->flags.usb2_mode,
sc->sc_rt_addr);
- if (udev->device_index == 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->flags.usb2_mode != USB_MODE_DEVICE) {
/* not supported */
return;
@@ -2466,5 +2308,5 @@
.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,
};
==== //depot/projects/usb/src/sys/dev/usb/controller/at91dci.h#2 (text+ko) ====
@@ -204,8 +204,6 @@
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;
==== //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#15 (text+ko) ====
@@ -81,8 +81,6 @@
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_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 @@
}
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 @@
/* 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 @@
/* complete root HUB interrupt endpoint */
- usb2_sw_transfer(&sc->sc_root_intr,
- &atmegadci_root_intr_done);
+ atmegadci_root_intr(sc);
}
}
}
@@ -676,8 +668,7 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
/*------------------------------------------------------------------------*
* 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 @@
.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_PRODUCT, atmegadci_product);
static void
-atmegadci_root_ctrl_enter(struct usb2_xfer *xfer)
+atmegadci_roothub_exec(struct usb2_bus *bus)
{
- 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)
-{
- 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 @@
switch (value) {
case UHF_PORT_SUSPEND:
- atmegadci_wakeup_peer(xfer);
+ atmegadci_wakeup_peer(sc);
break;
case UHF_PORT_ENABLE:
@@ -2130,67 +2056,6 @@
}
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,25 +2178,8 @@
edesc->bEndpointAddress, udev->flags.usb2_mode,
sc->sc_rt_addr, udev->device_index);
- if (udev->device_index == 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 = &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->flags.usb2_mode != USB_MODE_DEVICE) {
/* not supported */
return;
@@ -2368,5 +2216,5 @@
.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,
};
==== //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.h#4 (text+ko) ====
@@ -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 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 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 */
==== //depot/projects/usb/src/sys/dev/usb/controller/ehci.c#12 (text+ko) ====
@@ -93,18 +93,13 @@
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 void ehci_root_intr(ehci_softc_t *sc);
-static usb2_sw_transfer_func_t ehci_root_intr_done;
-static usb2_sw_transfer_func_t ehci_root_ctrl_done;
-
struct ehci_std_temp {
ehci_softc_t *sc;
struct usb2_page_cache *pc;
@@ -1415,8 +1410,7 @@
/* 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 @@
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 @@
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 @@
}
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 @@
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 @@
/*------------------------------------------------------------------------*
* 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 @@
.bmAttributes = UC_SELF_POWERED,
.bMaxPower = 0 /* max power */
},
-
.ifcd = {
.bLength = sizeof(struct usb2_interface_descriptor),
.bDescriptorType = UDESC_INTERFACE,
@@ -3007,7 +2963,6 @@
.bInterfaceProtocol = UIPROTO_HSHUBSTT,
0
},
-
.endpd = {
.bLength = sizeof(struct usb2_endpoint_descriptor),
.bDescriptorType = UDESC_ENDPOINT,
@@ -3044,34 +2999,10 @@
}
static void
-ehci_root_ctrl_enter(struct usb2_xfer *xfer)
+ehci_roothub_exec(struct usb2_bus *bus)
{
- 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_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 @@
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 @@
}
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 @@
/* 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:
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list