Changeset 8fe29a7c in mainline for uspace/drv/bus/usb/xhci/endpoint.c


Ignore:
Timestamp:
2018-01-18T17:12:53Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41abf3c
Parents:
fb28cde
Message:

xhci: clear endpoint halted condition

File:
1 edited

Legend:

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

    rfb28cde r8fe29a7c  
    316316}
    317317
     318uint8_t xhci_endpoint_get_state(xhci_endpoint_t *ep)
     319{
     320        assert(ep);
     321
     322        xhci_device_t *dev = xhci_device_get(ep->base.device);
     323        if (!dev->slot_id)
     324                return EP_STATE_DISABLED;
     325
     326        unsigned idx = xhci_endpoint_index(ep);
     327        xhci_device_ctx_t *ctx = dev->dev_ctx.virt;
     328        xhci_ep_ctx_t *ep_ctx = &ctx->endpoint_ctx[idx];
     329
     330        return XHCI_EP_STATE(*ep_ctx);
     331}
     332
     333/**
     334 * Clear endpoint halt condition by resetting the endpoint and skipping the
     335 * offending transfer.
     336 */
     337int xhci_endpoint_clear_halt(xhci_endpoint_t *ep, unsigned stream_id)
     338{
     339        int err;
     340
     341        xhci_device_t * const dev = xhci_device_get(ep->base.device);
     342        xhci_bus_t * const bus = bus_to_xhci_bus(dev->base.bus);
     343        xhci_hc_t * const hc = bus->hc;
     344
     345        const unsigned slot_id = dev->slot_id;
     346        const unsigned dci = xhci_endpoint_dci(ep);
     347
     348        if ((err = hc_reset_endpoint(hc, slot_id, dci)))
     349                return err;
     350
     351        uintptr_t addr;
     352
     353        xhci_trb_ring_reset_dequeue_state(&ep->ring, &addr);
     354
     355        if ((err = xhci_cmd_sync_inline(hc, SET_TR_DEQUEUE_POINTER,
     356                            .slot_id = slot_id,
     357                            .endpoint_id = dci,
     358                            .stream_id = stream_id,
     359                            .dequeue_ptr = addr,
     360                        )))
     361                return err;
     362
     363        return EOK;
     364}
     365
    318366/**
    319367 * @}
Note: See TracChangeset for help on using the changeset viewer.