Changeset 56db65d in mainline for uspace/drv/bus


Ignore:
Timestamp:
2017-10-24T11:06:32Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0206d35
Parents:
894f58c
Message:

usbhost: provide usb_endpoint_desc_t to bus when registering endpoint

This finishes the path of arbitrary information fetched from device all the way down to registering the endpoint in the bus.

Location:
uspace/drv/bus/usb
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_bus.c

    r894f58c r56db65d  
    114114
    115115
    116 static int ehci_register_ep(bus_t *bus_base, endpoint_t *ep)
     116static int ehci_register_ep(bus_t *bus_base, endpoint_t *ep, const usb_endpoint_desc_t *desc)
    117117{
    118118        ehci_bus_t *bus = (ehci_bus_t *) bus_base;
    119119        ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
    120120
    121         const int err = bus->parent_ops.register_endpoint(bus_base, ep);
     121        // TODO utilize desc->usb2
     122
     123        const int err = bus->parent_ops.register_endpoint(bus_base, ep, desc);
    122124        if (err)
    123125                return err;
  • uspace/drv/bus/usb/ohci/ohci_bus.c

    r894f58c r56db65d  
    115115
    116116
    117 static int ohci_register_ep(bus_t *bus_base, endpoint_t *ep)
     117static int ohci_register_ep(bus_t *bus_base, endpoint_t *ep, const usb_endpoint_desc_t *desc)
    118118{
    119119        ohci_bus_t *bus = (ohci_bus_t *) bus_base;
    120120        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    121121
    122         const int err = bus->parent_ops.register_endpoint(bus_base, ep);
     122        const int err = bus->parent_ops.register_endpoint(bus_base, ep, desc);
    123123        if (err)
    124124                return err;
  • uspace/drv/bus/usb/xhci/bus.c

    r894f58c r56db65d  
    165165}
    166166
    167 static int register_endpoint(bus_t *bus_base, endpoint_t *ep)
     167static int register_endpoint(bus_t *bus_base, endpoint_t *ep, const usb_endpoint_desc_t *desc)
    168168{
    169169        xhci_bus_t *bus = bus_to_xhci_bus(bus_base);
    170170        assert(bus);
    171171
    172         usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->target.address, ep->target.endpoint);
     172        assert(ep->device);
     173
     174        /* Extract USB2-related information from endpoint_desc */
     175        ep->target = (usb_target_t) {{
     176                .address = ep->device->address,
     177                .endpoint = desc->endpoint_no,
     178        }};
     179        ep->direction = desc->direction;
     180        ep->transfer_type = desc->transfer_type;
     181        ep->max_packet_size = desc->max_packet_size;
     182        ep->packets = desc->packets;
    173183
    174184        xhci_device_t *xhci_dev = xhci_device_get(ep->device);
    175185        xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep);
     186
     187        xhci_ep->max_streams = desc->usb3.max_streams;
     188        xhci_ep->max_burst = desc->usb3.max_burst;
     189        // TODO add this property to usb_endpoint_desc_t and fetch it from ss companion desc
     190        xhci_ep->mult = 0;
     191
     192        usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->target.address, ep->target.endpoint);
    176193        return xhci_device_add_endpoint(xhci_dev, xhci_ep);
    177194}
  • uspace/drv/bus/usb/xhci/endpoint.c

    r894f58c r56db65d  
    275275        assert(&dev->base == ep->base.device);
    276276        assert(dev->base.address == ep->base.target.address);
     277
     278        // TODO Do not fail hard on runtime conditions
    277279        assert(!dev->endpoints[ep_num]);
    278280
     
    285287                return EOK;
    286288        }
    287 
    288         // FIXME: Set these from usb_superspeed_endpoint_companion_descriptor_t:
    289         ep->max_streams = 0;
    290         ep->max_burst = 0;
    291         ep->mult = 0;
    292289
    293290        /* Set up TRB ring / PSA. */
  • uspace/drv/bus/usb/xhci/rh.c

    r894f58c r56db65d  
    9090}
    9191
     92/* FIXME Are these really static? Older HCs fetch it from descriptor. */
     93/* FIXME Add USB3 options, if applicable. */
     94static const usb_endpoint_desc_t ep0_desc = {
     95        .endpoint_no = 0,
     96        .direction = USB_DIRECTION_BOTH,
     97        .transfer_type = USB_TRANSFER_CONTROL,
     98        .max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE,
     99        .packets = 1,
     100};
     101
    92102// TODO: This currently assumes the device is attached to rh directly.
    93103//       Also, we should consider moving a lot of functionailty to xhci bus
     
    112122
    113123        xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base);
    114         /* FIXME: Sync this with xhci_device_add_endpoint. */
    115         ep0->max_streams = 0;
    116         ep0->max_burst = 0;
    117         ep0->mult = 0;
    118124
    119125        if ((err = xhci_endpoint_alloc_transfer_ds(ep0)))
     
    144150        fibril_mutex_unlock(&dev->guard);
    145151
    146         // XXX: Going around bus, duplicating code
    147152        ep0_base->device = dev;
    148         ep0_base->target.address = dev->address;
    149         ep0_base->target.endpoint = 0;
    150         ep0_base->direction = USB_DIRECTION_BOTH;
    151         ep0_base->transfer_type = USB_TRANSFER_CONTROL;
    152         ep0_base->max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE;
    153         ep0_base->packets = 1;
    154         ep0_base->bandwidth = CTRL_PIPE_MIN_PACKET_SIZE;
    155 
    156         bus_register_endpoint(&rh->hc->bus.base, ep0_base);
     153
     154        bus_register_endpoint(&rh->hc->bus.base, ep0_base, &ep0_desc);
    157155
    158156        if (!rh->devices[dev->port - 1]) {
Note: See TracChangeset for help on using the changeset viewer.