Changeset 2cf28b9 in mainline for uspace/drv/bus/usb/xhci/bus.c


Ignore:
Timestamp:
2017-10-25T15:22:45Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
62558202
Parents:
f668d60
Message:

xhci: connecting devices deeper than to roothub

It still does not work, because the address command fails, but there should not be any fundamental problem.

File:
1 edited

Legend:

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

    rf668d60 r2cf28b9  
    4545#include <stdbool.h>
    4646
     47#include "hc.h"
    4748#include "bus.h"
    4849#include "endpoint.h"
     
    136137        }
    137138
     139        /* Calculate route string */
     140        xhci_device_t *xhci_hub = xhci_device_get(dev->hub);
     141        xhci_dev->tier = xhci_hub->tier + 1;
     142        xhci_dev->route_str = xhci_hub->route_str;
     143
     144        /* Roothub port is not part of the route string */
     145        if (xhci_dev->tier >= 2) {
     146                const unsigned offset = 4 * (xhci_dev->tier - 2);
     147                xhci_dev->route_str |= (dev->port & 0xf) << offset;
     148        }
     149
     150        fibril_mutex_lock(&bus->base.guard);
    138151        /* Assign an address to the device */
    139152        if ((err = address_device(hc, xhci_dev))) {
     
    147160        assert(bus->devices_by_slot[xhci_dev->slot_id] == NULL);
    148161        bus->devices_by_slot[xhci_dev->slot_id] = xhci_dev;
     162        fibril_mutex_unlock(&bus->base.guard);
    149163
    150164        /* Read the device descriptor, derive the match ids */
     
    305319}
    306320
     321static int request_address(bus_t *bus_base, usb_address_t *addr, bool strict, usb_speed_t speed)
     322{
     323        assert(addr);
     324
     325        if (*addr != USB_ADDRESS_DEFAULT)
     326                /* xHCI does not allow software to assign addresses. */
     327                return ENOTSUP;
     328
     329        assert(strict);
     330
     331        xhci_bus_t *xhci_bus = bus_to_xhci_bus(bus_base);
     332
     333        if (xhci_bus->default_address_speed != USB_SPEED_MAX)
     334                /* Already allocated */
     335                return ENOENT;
     336
     337        xhci_bus->default_address_speed = speed;
     338        return EOK;
     339}
     340
     341static int release_address(bus_t *bus_base, usb_address_t addr)
     342{
     343        if (addr != USB_ADDRESS_DEFAULT)
     344                return ENOTSUP;
     345
     346        xhci_bus_t *xhci_bus = bus_to_xhci_bus(bus_base);
     347
     348        xhci_bus->default_address_speed = USB_SPEED_MAX;
     349        return EOK;
     350}
     351
    307352static usb_transfer_batch_t *create_batch(bus_t *bus, endpoint_t *ep)
    308353{
     
    327372        .find_endpoint = find_endpoint,
    328373
    329         .request_address = NULL,
    330         .release_address = NULL,
     374        .request_address = request_address,
     375        .release_address = release_address,
    331376        .reset_toggle = reset_toggle,
    332377
     
    351396
    352397        bus->base.ops = xhci_bus_ops;
     398        bus->default_address_speed = USB_SPEED_MAX;
    353399        return EOK;
    354400}
Note: See TracChangeset for help on using the changeset viewer.