mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
usb: composite: add BOS descriptor support to composite framework
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Roger Quadros <rogerq@ti.com>
This commit is contained in:
parent
d80effb184
commit
f69257baa8
3 changed files with 67 additions and 6 deletions
|
@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
req->status, req->actual, req->length);
|
req->status, req->actual, req->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bos_desc(struct usb_composite_dev *cdev)
|
||||||
|
{
|
||||||
|
struct usb_ext_cap_descriptor *usb_ext;
|
||||||
|
struct usb_bos_descriptor *bos = cdev->req->buf;
|
||||||
|
|
||||||
|
bos->bLength = USB_DT_BOS_SIZE;
|
||||||
|
bos->bDescriptorType = USB_DT_BOS;
|
||||||
|
|
||||||
|
bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE);
|
||||||
|
bos->bNumDeviceCaps = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A SuperSpeed device shall include the USB2.0 extension descriptor
|
||||||
|
* and shall support LPM when operating in USB2.0 HS mode.
|
||||||
|
*/
|
||||||
|
usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
|
||||||
|
bos->bNumDeviceCaps++;
|
||||||
|
le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);
|
||||||
|
usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
|
||||||
|
usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
|
||||||
|
usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
|
||||||
|
usb_ext->bmAttributes =
|
||||||
|
cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The Superspeed USB Capability descriptor shall be implemented
|
||||||
|
* by all SuperSpeed devices.
|
||||||
|
*/
|
||||||
|
if (gadget_is_superspeed(cdev->gadget)) {
|
||||||
|
struct usb_ss_cap_descriptor *ss_cap;
|
||||||
|
|
||||||
|
ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
|
||||||
|
bos->bNumDeviceCaps++;
|
||||||
|
le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
|
||||||
|
ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
|
||||||
|
ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
|
||||||
|
ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
|
||||||
|
ss_cap->bmAttributes = 0; /* LTM is not supported yet */
|
||||||
|
ss_cap->wSpeedSupported =
|
||||||
|
cpu_to_le16(USB_LOW_SPEED_OPERATION |
|
||||||
|
USB_FULL_SPEED_OPERATION |
|
||||||
|
USB_HIGH_SPEED_OPERATION |
|
||||||
|
USB_5GBPS_OPERATION);
|
||||||
|
ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
|
||||||
|
ss_cap->bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT;
|
||||||
|
ss_cap->bU2DevExitLat =
|
||||||
|
cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT);
|
||||||
|
}
|
||||||
|
return le16_to_cpu(bos->wTotalLength);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The setup() callback implements all the ep0 functionality that's
|
* The setup() callback implements all the ep0 functionality that's
|
||||||
* not handled lower down, in hardware or the hardware driver(like
|
* not handled lower down, in hardware or the hardware driver(like
|
||||||
|
@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
|
||||||
value = min(w_length, (u16) value);
|
value = min(w_length, (u16) value);
|
||||||
break;
|
break;
|
||||||
case USB_DT_BOS:
|
case USB_DT_BOS:
|
||||||
/*
|
if (gadget_is_superspeed(cdev->gadget))
|
||||||
* The USB compliance test (USB 2.0 Command Verifier)
|
value = bos_desc(cdev);
|
||||||
* issues this request. We should not run into the
|
if (value >= 0)
|
||||||
* default path here. But return for now until
|
value = min(w_length, (u16)value);
|
||||||
* the superspeed support is added.
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto unknown;
|
goto unknown;
|
||||||
|
|
|
@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */
|
||||||
__le16 bU2DevExitLat;
|
__le16 bU2DevExitLat;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */
|
||||||
|
#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4 /* Less then 500 microsec */
|
||||||
|
|
||||||
#define USB_DT_USB_SS_CAP_SIZE 10
|
#define USB_DT_USB_SS_CAP_SIZE 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -591,6 +591,15 @@ static inline int gadget_is_otg(struct usb_gadget *g)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gadget_is_superspeed() - return true if the hardware handles superspeed
|
||||||
|
* @g: controller that might support superspeed
|
||||||
|
*/
|
||||||
|
static inline int gadget_is_superspeed(struct usb_gadget *g)
|
||||||
|
{
|
||||||
|
return g->max_speed >= USB_SPEED_SUPER;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* usb_gadget_frame_number - returns the current frame number
|
* usb_gadget_frame_number - returns the current frame number
|
||||||
* @gadget: controller that reports the frame number
|
* @gadget: controller that reports the frame number
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue