diff options
Diffstat (limited to 'sys/dev/usb/controller/musb_otg.c')
-rw-r--r-- | sys/dev/usb/controller/musb_otg.c | 186 |
1 files changed, 15 insertions, 171 deletions
diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index 23af416..f16d47e 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -80,8 +80,6 @@ struct usb2_pipe_methods musbotg_device_bulk_methods; 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 *); static void musbotg_interrupt_poll(struct musbotg_softc *); - -static usb2_sw_transfer_func_t musbotg_root_intr_done; -static usb2_sw_transfer_func_t musbotg_root_ctrl_done; +static void musbotg_root_intr(struct musbotg_softc *); /* * Here is a configuration that the chip supports. @@ -201,9 +196,8 @@ musbotg_pull_down(struct musbotg_softc *sc) } static void -musbotg_wakeup_peer(struct usb2_xfer *xfer) +musbotg_wakeup_peer(struct musbotg_softc *sc) { - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); uint8_t temp; if (!(sc->sc_flags.status_suspend)) { @@ -965,9 +959,7 @@ musbotg_vbus_interrupt(struct musbotg_softc *sc, uint8_t is_on) sc->sc_flags.status_vbus = 1; /* complete root HUB interrupt endpoint */ - - usb2_sw_transfer(&sc->sc_root_intr, - &musbotg_root_intr_done); + musbotg_root_intr(sc); } } else { if (sc->sc_flags.status_vbus) { @@ -978,9 +970,7 @@ musbotg_vbus_interrupt(struct musbotg_softc *sc, uint8_t is_on) sc->sc_flags.change_connect = 1; /* complete root HUB interrupt endpoint */ - - usb2_sw_transfer(&sc->sc_root_intr, - &musbotg_root_intr_done); + musbotg_root_intr(sc); } } @@ -1074,9 +1064,7 @@ repeat: } } /* complete root HUB interrupt endpoint */ - - usb2_sw_transfer(&sc->sc_root_intr, - &musbotg_root_intr_done); + musbotg_root_intr(sc); } /* check for any endpoint interrupts */ @@ -1320,31 +1308,17 @@ musbotg_start_standard_chain(struct usb2_xfer *xfer) } static void -musbotg_root_intr_done(struct usb2_xfer *xfer, - struct usb2_sw_transfer *std) +musbotg_root_intr(struct musbotg_softc *sc) { - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); - DPRINTFN(8, "\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 */ - musbotg_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 @@ -1887,7 +1861,6 @@ musbotg_do_poll(struct usb2_bus *bus) USB_BUS_LOCK(&sc->sc_bus); musbotg_interrupt_poll(sc); - musbotg_root_ctrl_poll(sc); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -2102,29 +2075,8 @@ struct usb2_pipe_methods musbotg_device_isoc_methods = /*------------------------------------------------------------------------* * musbotg 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 -musbotg_root_ctrl_open(struct usb2_xfer *xfer) -{ - return; -} - -static void -musbotg_root_ctrl_close(struct usb2_xfer *xfer) -{ - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); - - if (sc->sc_root_ctrl.xfer == xfer) { - sc->sc_root_ctrl.xfer = NULL; - } - musbotg_device_done(xfer, USB_ERR_CANCELLED); -} - -/* - * USB descriptors for the virtual Root HUB: - */ static const struct usb2_device_descriptor musbotg_devd = { .bLength = sizeof(struct usb2_device_descriptor), @@ -2170,7 +2122,6 @@ static const struct musbotg_config_desc musbotg_confd = { .bInterfaceSubClass = UISUBCLASS_HUB, .bInterfaceProtocol = UIPROTO_HSHUBSTT, }, - .endpd = { .bLength = sizeof(struct usb2_endpoint_descriptor), .bDescriptorType = UDESC_ENDPOINT, @@ -2211,44 +2162,15 @@ USB_MAKE_STRING_DESC(STRING_VENDOR, musbotg_vendor); USB_MAKE_STRING_DESC(STRING_PRODUCT, musbotg_product); static void -musbotg_root_ctrl_enter(struct usb2_xfer *xfer) +musbotg_roothub_exec(struct usb2_bus *bus) { - return; -} - -static void -musbotg_root_ctrl_start(struct usb2_xfer *xfer) -{ - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); - - sc->sc_root_ctrl.xfer = xfer; - - usb2_bus_roothub_exec(xfer->xroot->bus); -} - -static void -musbotg_root_ctrl_task(struct usb2_bus *bus) -{ - musbotg_root_ctrl_poll(MUSBOTG_BUS2SC(bus)); -} - -static void -musbotg_root_ctrl_done(struct usb2_xfer *xfer, - struct usb2_sw_transfer *std) -{ - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); + struct musbotg_softc *sc = MUSBOTG_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 */ - musbotg_device_done(xfer, std->err); - } - goto done; - } /* buffer reset */ std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0); std->len = 0; @@ -2507,7 +2429,7 @@ tr_handle_clear_port_feature: switch (value) { case UHF_PORT_SUSPEND: - musbotg_wakeup_peer(xfer); + musbotg_wakeup_peer(sc); break; case UHF_PORT_ENABLE: @@ -2634,67 +2556,6 @@ done: } static void -musbotg_root_ctrl_poll(struct musbotg_softc *sc) -{ - usb2_sw_transfer(&sc->sc_root_ctrl, - &musbotg_root_ctrl_done); -} - -struct usb2_pipe_methods musbotg_root_ctrl_methods = -{ - .open = musbotg_root_ctrl_open, - .close = musbotg_root_ctrl_close, - .enter = musbotg_root_ctrl_enter, - .start = musbotg_root_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 0, -}; - -/*------------------------------------------------------------------------* - * musbotg root interrupt support - *------------------------------------------------------------------------*/ -static void -musbotg_root_intr_open(struct usb2_xfer *xfer) -{ - return; -} - -static void -musbotg_root_intr_close(struct usb2_xfer *xfer) -{ - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); - - if (sc->sc_root_intr.xfer == xfer) { - sc->sc_root_intr.xfer = NULL; - } - musbotg_device_done(xfer, USB_ERR_CANCELLED); -} - -static void -musbotg_root_intr_enter(struct usb2_xfer *xfer) -{ - return; -} - -static void -musbotg_root_intr_start(struct usb2_xfer *xfer) -{ - struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); - - sc->sc_root_intr.xfer = xfer; -} - -struct usb2_pipe_methods musbotg_root_intr_methods = -{ - .open = musbotg_root_intr_open, - .close = musbotg_root_intr_close, - .enter = musbotg_root_intr_enter, - .start = musbotg_root_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, -}; - -static void musbotg_xfer_setup(struct usb2_setup_params *parm) { const struct usb2_hw_ep_profile *pf; @@ -2818,24 +2679,7 @@ musbotg_pipe_init(struct usb2_device *udev, struct usb2_endpoint_descriptor *ede 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 = &musbotg_root_ctrl_methods; - break; - case UE_DIR_IN | MUSBOTG_INTR_ENDPT: - pipe->methods = &musbotg_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 */ @@ -2874,5 +2718,5 @@ struct usb2_bus_methods musbotg_bus_methods = .get_hw_ep_profile = &musbotg_get_hw_ep_profile, .set_stall = &musbotg_set_stall, .clear_stall = &musbotg_clear_stall, - .roothub_exec = &musbotg_root_ctrl_task, + .roothub_exec = &musbotg_roothub_exec, }; |