Changeset 8db42f7 in mainline


Ignore:
Timestamp:
2017-07-13T15:13:12Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
665bf3c
Parents:
5ac5eb1
Message:

Added ADDRESS DEVICE command sender and a basic handler.

Location:
uspace/drv/bus/usb/xhci
Files:
2 edited

Legend:

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

    r5ac5eb1 r8db42f7  
    4141#include "debug.h"
    4242#include "hc.h"
     43#include "hw_struct/context.h"
    4344#include "hw_struct/trb.h"
    4445
     
    9697}
    9798
     99int xhci_send_address_device_command(xhci_hc_t *hc, uint32_t slot_id,
     100                                     xhci_input_ctx_t *ictx)
     101{
     102        /**
     103         * TODO: Requirements for this command:
     104         *           dcbaa[slot_id] is properly sized and initialized
     105         *           ictx has valids slot context and endpoint 0, all
     106         *           other should be ignored at this point (see section 4.6.5).
     107         */
     108        xhci_trb_t trb;
     109        memset(&trb, 0, sizeof(trb));
     110
     111        uint64_t phys_addr = (uint64_t) addr_to_phys(ictx);
     112        trb.parameter = host2xhci(32, phys_addr & 0xFFFFFFFFFFFFFFF0);
     113
     114        /**
     115         * Note: According to section 6.4.3.4, we can set the 9th bit
     116         *       of the control field of the trb (BSR) to 1 and then the xHC
     117         *       will not issue the SET_ADDRESS request to the USB device.
     118         *       This can be used to provide compatibility with legacy USB devices
     119         *       that require their device descriptor to be read before such request.
     120         */
     121        trb.control = host2xhci(32, XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD << 10);
     122        trb.control |= host2xhci(32, hc->command_ring.pcs);
     123        trb.control |= host2xhci(32, slot_id << 24);
     124
     125        return enqueue_trb(hc, &trb, 0, 0);
     126}
     127
    98128int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb)
    99129{
     
    123153                //       data structures once it's implemented.
    124154                break;
     155        case XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD:
     156                if (code == XHCI_TRBC_SLOT_NOT_ENABLED_ERROR)
     157                        usb_log_debug2("Slot to be addressed was not enabled.");
     158                else if (code == XHCI_TRBC_CONTEXT_STATE_ERROR)
     159                        usb_log_debug2("Slot to be addressed is not in enabled or default state.");
     160                else if (code == XHCI_TRBC_USB_TRANSACTION_ERROR)
     161                        usb_log_debug2("SET_ADDRESS request to the USB device failed.");
     162                // TODO: Call set address callback when it's implemented.
     163                break;
    125164        default:
    126165                usb_log_debug2("Unsupported command trb.");
  • uspace/drv/bus/usb/xhci/commands.h

    r5ac5eb1 r8db42f7  
    3939typedef struct xhci_hc xhci_hc_t;
    4040typedef struct xhci_trb xhci_trb_t;
     41typedef struct xhci_input_ctx xhci_input_ctx_t;
    4142
    4243int xhci_send_no_op_command(xhci_hc_t *);
    4344int xhci_send_enable_slot_command(xhci_hc_t *);
    4445int xhci_send_disable_slot_command(xhci_hc_t *, uint32_t);
     46int xhci_send_address_device_command(xhci_hc_t *, uint32_t, xhci_input_ctx_t *);
    4547
    4648int xhci_handle_command_completion(xhci_hc_t *, xhci_trb_t *);
Note: See TracChangeset for help on using the changeset viewer.