From: Vipin KUMAR vipin.ku...@st.com
This patch adds the support for high speed in usb device framework and usbtty
driver. This feature has been kept within a macro CONFIG_USBD_HS, so the board
configuration files have to define this macro to enable high speed support.
Along with that specific peripheral drivers also need to define a function to
let the framework know that the enumeration has happened at high speed.
This function prototype is int is_usbd_high_speed(void)
Signed-off-by: Vipin Kumar vipin.ku...@st.com
Signed-off-by: Amit Virdi amit.vi...@st.com
---
README|8 +++
drivers/serial/usbtty.c | 50 -
drivers/serial/usbtty.h |4 +++
drivers/usb/gadget/core.c |1 -
drivers/usb/gadget/ep0.c | 23 +---
include/usbdescriptors.h | 15 +
include/usbdevice.h | 22 ++-
7 files changed, 116 insertions(+), 7 deletions(-)
diff --git a/README b/README
index b69a3b6..0ab6892 100644
--- a/README
+++ b/README
@@ -1148,6 +1148,14 @@ The following options need to be configured:
Define this to have a tty type of device available to
talk to the UDC device
+ CONFIG_USBD_HS
+ Define this to enable the high speed support for usb
+ device and usbtty. If this feature is enabled, a routine
+ int is_usbd_high_speed(void)
+ also needs to be defined by the driver to dynamically
poll
+ whether the enumeration has succeded at high speed or
full
+ speed.
+
CONFIG_SYS_CONSOLE_IS_IN_ENV
Define this if you want stdin, stdout /or stderr to
be set to usbtty.
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 550bc58..148d1a6 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -133,6 +133,19 @@ static struct usb_device_descriptor device_descriptor = {
};
+#if defined(CONFIG_USBD_HS)
+static struct usb_qualifier_descriptor qualifier_descriptor = {
+ .bLength = sizeof(struct usb_qualifier_descriptor),
+ .bDescriptorType = USB_DT_QUAL,
+ .bcdUSB = cpu_to_le16(USB_BCD_VERSION),
+ .bDeviceClass = COMMUNICATIONS_DEVICE_CLASS,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ .bMaxPacketSize0 = EP0_MAX_PACKET_SIZE,
+ .bNumConfigurations = NUM_CONFIGS
+};
+#endif
+
/*
* Static CDC ACM specific descriptors
*/
@@ -638,6 +651,9 @@ static void usbtty_init_instances (void)
memset (device_instance, 0, sizeof (struct usb_device_instance));
device_instance-device_state = STATE_INIT;
device_instance-device_descriptor = device_descriptor;
+#if defined(CONFIG_USBD_HS)
+ device_instance-qualifier_descriptor = qualifier_descriptor;
+#endif
device_instance-event = usbtty_event_handler;
device_instance-cdc_recv_setup = usbtty_cdc_setup;
device_instance-bus = bus_instance;
@@ -751,6 +767,10 @@ static void usbtty_init_terminal_type(short type)
device_descriptor.idProduct =
cpu_to_le16(CONFIG_USBD_PRODUCTID_CDCACM);
+#if defined(CONFIG_USBD_HS)
+ qualifier_descriptor.bDeviceClass =
+ COMMUNICATIONS_DEVICE_CLASS;
+#endif
/* Assign endpoint indices */
tx_endpoint = ACM_TX_ENDPOINT;
rx_endpoint = ACM_RX_ENDPOINT;
@@ -779,7 +799,9 @@ static void usbtty_init_terminal_type(short type)
device_descriptor.bDeviceClass = 0xFF;
device_descriptor.idProduct =
cpu_to_le16(CONFIG_USBD_PRODUCTID_GSERIAL);
-
+#if defined(CONFIG_USBD_HS)
+ qualifier_descriptor.bDeviceClass = 0xFF;
+#endif
/* Assign endpoint indices */
tx_endpoint = GSERIAL_TX_ENDPOINT;
rx_endpoint = GSERIAL_RX_ENDPOINT;
@@ -932,6 +954,9 @@ static int usbtty_configured (void)
static void usbtty_event_handler (struct usb_device_instance *device,
usb_device_event_t event, int data)
{
+#if defined(CONFIG_USBD_HS)
+ int i;
+#endif
switch (event) {
case DEVICE_RESET:
case DEVICE_BUS_INACTIVE:
@@ -942,6 +967,29 @@ static void usbtty_event_handler (struct
usb_device_instance *device,
break;
case DEVICE_ADDRESS_ASSIGNED:
+#if defined(CONFIG_USBD_HS)
+ /*
+* is_usbd_high_speed routine needs to be defined by
+* specific gadget driver
+* It returns TRUE if device enumerates at High speed
+*