Changeset 481af21e in mainline


Ignore:
Timestamp:
2017-07-12T19:44:01Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f8315ed
Parents:
fd9f4ffe
Message:

Moved common tail of command sending functions into a separate function, fixed trb setup for enable slot command.

File:
1 edited

Legend:

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

    rfd9f4ffe r481af21e  
    4343#include "hw_struct/trb.h"
    4444
    45 static int ring_doorbell(xhci_hc_t *hc, unsigned doorbell, unsigned target)
     45static inline int ring_doorbell(xhci_hc_t *hc, unsigned doorbell, unsigned target)
    4646{
    4747        uint32_t v = host2xhci(32, target & BIT_RRANGE(uint32_t, 7));
    4848        pio_write_32(&hc->db_arry[doorbell], v);
     49        return EOK;
     50}
     51
     52static inline int enqueue_trb(xhci_hc_t *hc, xhci_trb_t *trb,
     53                              unsigned doorbell, unsigned target)
     54{
     55        xhci_trb_ring_enqueue(&hc->command_ring, trb);
     56        ring_doorbell(hc, doorbell, target);
     57
     58        xhci_dump_trb(trb);
     59        usb_log_debug2("HC(%p): Sent TRB", hc);
     60
    4961        return EOK;
    5062}
     
    5769        trb.control = host2xhci(32, XHCI_TRB_TYPE_NO_OP_CMD << 10);
    5870
    59         xhci_trb_ring_enqueue(&hc->command_ring, &trb);
    60         ring_doorbell(hc, 0, 0);
    61 
    62         xhci_dump_trb(&trb);
    63         usb_log_debug2("HC(%p): Sent TRB", hc);
    64         return EOK;
     71        return enqueue_trb(hc, &trb, 0, 0);
    6572}
    6673
     
    7279        trb.control = host2xhci(32, XHCI_TRB_TYPE_ENABLE_SLOT_CMD << 10);
    7380        trb.control |= host2xhci(32, XHCI_REG_RD(hc->xecp, XHCI_EC_SP_SLOT_TYPE) << 16);
     81        trb.control |= host2xhci(32, hc->command_ring.pcs);
    7482
    7583        // TODO: Setup input control context.
    7684
    77         xhci_trb_ring_enqueue(&hc->command_ring, &trb);
    78         ring_doorbell(hc, 0, 0);
    79 
    80         xhci_dump_trb(&trb);
    81         usb_log_debug2("HC(%p): Sent TRB", hc);
    82         return EOK;
     85        return enqueue_trb(hc, &trb, 0, 0);
    8386}
    8487
Note: See TracChangeset for help on using the changeset viewer.