DM USB: xHCI: Support control transfer for USB port mapper.

This patch implements the control transfer for port mapper. With this
patch, USB2.0 device can be enumerated successfully in user OS.

Change-Id: I567bd00ca310d68375acd94a5cc5bcd287665df1
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Wu, Xiaoguang
2018-05-17 11:09:56 +08:00
committed by lijinxia
parent b12527f35d
commit caf4916e99
4 changed files with 377 additions and 3 deletions

View File

@@ -31,13 +31,39 @@
#include <stdlib.h>
#include <pthread.h>
#include <stdbool.h>
#include "types.h"
#define USB_MAX_XFER_BLOCKS 8
#define USB_XFER_OUT 0
#define USB_XFER_IN 1
#define USB_DIR_OUT 0
#define USB_DIR_IN 0x80
#define LIBUSB_TIMEOUT 10000
#define USB_CFG_ATT_ONE (1 << 7) /* should always be set */
#define USB_CFG_ATT_SELFPOWER (1 << 6)
#define USB_CFG_ATT_WAKEUP (1 << 5)
#define USB_CFG_ATT_BATTERY (1 << 4)
enum endpoint_type {
USB_ENDPOINT_CONTROL = 0,
USB_ENDPOINT_ISOC,
USB_ENDPOINT_BULK,
USB_ENDPOINT_INT,
USB_ENDPOINT_INVALID = 255
};
#define USB_INTERFACE_INVALID 255
enum token_type {
TOKEN_OUT = 0,
TOKEN_IN,
TOKEN_SETUP
};
struct usb_hci;
struct usb_device_request;
struct usb_data_xfer;
@@ -108,6 +134,7 @@ struct usb_data_xfer {
int ndata; /* # of data items */
int head;
int tail;
int status;
pthread_mutex_t mtx;
};

View File

@@ -32,10 +32,18 @@
#ifndef _USB_DEVICE_H
#define _USB_DEVICE_H
#include <libusb-1.0/libusb.h>
#include "usb_core.h"
#define USB_NUM_INTERFACE 16
#define USB_NUM_ENDPOINT 15
#define USB_EP_ADDR(d) ((d)->bEndpointAddress)
#define USB_EP_ATTR(d) ((d)->bmAttributes)
#define USB_EP_PID(d) (USB_EP_ADDR(d) & USB_DIR_IN ? TOKEN_IN : TOKEN_OUT)
#define USB_EP_TYPE(d) (USB_EP_ATTR(d) & 0x3)
#define USB_EP_NR(d) (USB_EP_ADDR(d) & 0xF)
#define USB_EP_ERR_TYPE 0xFF
enum {
USB_INFO_VERSION,
USB_INFO_SPEED,
@@ -106,4 +114,6 @@ int usb_dev_sys_init(usb_dev_sys_cb conn_cb, usb_dev_sys_cb disconn_cb,
void *usb_dev_init(void *pdata, char *opt);
void usb_dev_deinit(void *pdata);
int usb_dev_info(void *pdata, int type, void *value, int size);
int usb_dev_request(void *pdata, struct usb_data_xfer *xfer);
int usb_dev_reset(void *pdata);
#endif