Changeset 306a36d in mainline for uspace/drv/bus/usb/xhci


Ignore:
Timestamp:
2017-11-19T23:43:31Z (8 years ago)
Author:
Aearsis <Hlavaty.Ondrej@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ff14aede
Parents:
e76c0ea
Message:

xhci: configuration of endpoint 0

Moved fetching of the first 8B of device descriptor from usb2_bus to
hcd, and using it in xhci bus. Also, the value was previously read wrong
by the endpoint descriptor macros, although the value is raw in the
device descriptor - now fixed.

Location:
uspace/drv/bus/usb/xhci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/bus.c

    re76c0ea r306a36d  
    5050
    5151
    52 /* FIXME Are these really static? Older HCs fetch it from descriptor. */
    53 /* FIXME Add USB3 options, if applicable. */
    54 static const usb_endpoint_desc_t ep0_desc = {
     52static const usb_endpoint_desc_t ep0_initial_desc = {
    5553        .endpoint_no = 0,
    5654        .direction = USB_DIRECTION_BOTH,
     
    9795        xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base);
    9896
    99         if ((err = prepare_endpoint(ep0, &ep0_desc)))
     97        if ((err = prepare_endpoint(ep0, &ep0_initial_desc)))
    10098                goto err_ep;
    10199
     
    124122}
    125123
     124static int setup_ep0_packet_size(xhci_hc_t *hc, xhci_device_t *dev)
     125{
     126        int err;
     127
     128        uint16_t max_packet_size;
     129        if ((err = hcd_get_ep0_max_packet_size(&max_packet_size, hc->hcd, &dev->base)))
     130                return err;
     131
     132        xhci_endpoint_t *ep0 = dev->endpoints[0];
     133        assert(ep0);
     134
     135        if (ep0->base.max_packet_size == max_packet_size)
     136                return EOK;
     137
     138        ep0->base.max_packet_size = max_packet_size;
     139
     140        xhci_ep_ctx_t ep_ctx;
     141        xhci_setup_endpoint_context(ep0, &ep_ctx);
     142
     143        if ((err = hc_update_endpoint(hc, dev->slot_id, 0, &ep_ctx)))
     144                return err;
     145
     146        return EOK;
     147}
     148
    126149int xhci_bus_enumerate_device(xhci_bus_t *bus, xhci_hc_t *hc, device_t *dev)
    127150{
     
    160183        }
    161184
    162         // TODO: Fetch descriptor of EP0 and reconfigure it accordingly
    163         assert(xhci_dev->endpoints[0]);
     185        if ((err = setup_ep0_packet_size(hc, xhci_dev))) {
     186                usb_log_error("Failed to setup control endpoint of the new device: %s", str_error(err));
     187                goto err_address;
     188        }
    164189
    165190        assert(bus->devices_by_slot[xhci_dev->slot_id] == NULL);
  • uspace/drv/bus/usb/xhci/hc.c

    re76c0ea r306a36d  
    651651}
    652652
    653 // TODO: This currently assumes the device is attached to rh directly
    654 //      -> calculate route string
    655653int hc_address_device(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep0)
    656654{
     
    767765}
    768766
     767int hc_update_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx, xhci_ep_ctx_t *ep_ctx)
     768{
     769        dma_buffer_t ictx_dma_buf;
     770        const int err = dma_buffer_alloc(&ictx_dma_buf, sizeof(xhci_input_ctx_t));
     771        if (err)
     772                return err;
     773
     774        xhci_input_ctx_t *ictx = ictx_dma_buf.virt;
     775        memset(ictx, 0, sizeof(xhci_input_ctx_t));
     776
     777        XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1);
     778        memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t));
     779
     780        return xhci_cmd_sync_inline(hc, EVALUATE_CONTEXT, .slot_id = slot_id, .input_ctx = ictx_dma_buf);
     781}
     782
    769783/**
    770784 * @}
  • uspace/drv/bus/usb/xhci/hc.h

    re76c0ea r306a36d  
    110110int hc_add_endpoint(xhci_hc_t *, uint32_t, uint8_t, xhci_ep_ctx_t *);
    111111int hc_drop_endpoint(xhci_hc_t *, uint32_t, uint8_t);
     112int hc_update_endpoint(xhci_hc_t *, uint32_t, uint8_t, xhci_ep_ctx_t *);
    112113
    113114#endif
Note: See TracChangeset for help on using the changeset viewer.