Changeset 51c1d500 in mainline for uspace/drv/bus/usb/xhci/device.c


Ignore:
Timestamp:
2018-01-20T17:16:33Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6271a34
Parents:
abb5d08
Message:

xhci: move HC semantics from endpoint/device to hc module

File:
1 edited

Legend:

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

    rabb5d08 r51c1d500  
    5252#include "bus.h"
    5353#include "endpoint.h"
     54#include "hw_struct/context.h"
    5455
    5556#include "device.h"
     
    8687        dev->base.endpoints[0] = ep0_base;
    8788
    88         xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base);
    89 
    9089        /* Address device */
    91         if ((err = hc_address_device(dev, ep0)))
     90        if ((err = hc_address_device(dev)))
    9291                goto err_added;
    9392
     
    127126        ep0->base.max_transfer_size = max_packet_size * ep0->base.packets_per_uframe;
    128127
    129         xhci_ep_ctx_t ep_ctx;
    130         xhci_setup_endpoint_context(ep0, &ep_ctx);
    131 
    132         if ((err = hc_update_endpoint(dev, 0, &ep_ctx)))
     128        if ((err = hc_update_endpoint(ep0)))
    133129                return err;
    134130
     
    306302}
    307303
     304/**
     305 * Fill a slot context that is part of an Input Context with appropriate
     306 * values.
     307 *
     308 * @param ctx Slot context, zeroed out.
     309 */
     310void xhci_setup_slot_context(xhci_device_t *dev, xhci_slot_ctx_t *ctx)
     311{
     312        /* Initialize slot_ctx according to section 4.3.3 point 3. */
     313        XHCI_SLOT_ROOT_HUB_PORT_SET(*ctx, dev->rh_port);
     314        XHCI_SLOT_ROUTE_STRING_SET(*ctx, dev->route_str);
     315        XHCI_SLOT_SPEED_SET(*ctx, hc_speed_to_psiv(dev->base.speed));
     316
     317        /*
     318         * Note: This function is used even before this flag can be set, to
     319         *       issue the address device command. It is OK, because these
     320         *       flags are not required to be valid for that command.
     321         */
     322        if (dev->is_hub) {
     323                XHCI_SLOT_HUB_SET(*ctx, 1);
     324                XHCI_SLOT_NUM_PORTS_SET(*ctx, dev->num_ports);
     325                XHCI_SLOT_TT_THINK_TIME_SET(*ctx, dev->tt_think_time);
     326                XHCI_SLOT_MTT_SET(*ctx, 0); // MTT not supported yet
     327        }
     328
     329        /* Setup Transaction Translation. TODO: Test this with HS hub. */
     330        if (dev->base.tt.dev != NULL) {
     331                xhci_device_t *hub = xhci_device_get(dev->base.tt.dev);
     332                XHCI_SLOT_TT_HUB_SLOT_ID_SET(*ctx, hub->slot_id);
     333                XHCI_SLOT_TT_HUB_PORT_SET(*ctx, dev->base.tt.port);
     334        }
     335
     336        // As we always allocate space for whole input context, we can set this to maximum
     337        XHCI_SLOT_CTX_ENTRIES_SET(*ctx, 31);
     338}
     339
    308340
    309341/**
Note: See TracChangeset for help on using the changeset viewer.