Skip to contentSkip to conversation

Enable high speed support for USB device framework and usbtty

PATCH New Amit Virdi 2 participants 2 messages Mar 26, 2012 – Mar 28, 2012 USB

lore
Share & tools
lore

Amit Virdi

author
#0 lore raw

PATCH v2 1/1 Enable high speed support for USB device framework and usbtty

From: Vipin KUMAR <[email protected]>

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)"

---
 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(-)
README +8 -0
index b69a3b6..0ab6892 100644
@@ -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.
drivers/serial/usbtty.c +49 -1

86 lines not on this page · raw message

drivers/serial/usbtty.h +4 -0
index 6731c38..bd3bcbc 100644
@@ -72,6 +72,10 @@
 #define CONFIG_USBD_SERIAL_INT_PKTSIZE	UDC_INT_PACKET_SIZE
 #define CONFIG_USBD_SERIAL_BULK_PKTSIZE	UDC_BULK_PACKET_SIZE
 
+#if defined(CONFIG_USBD_HS)
+#define CONFIG_USBD_SERIAL_BULK_HS_PKTSIZE	UDC_BULK_HS_PACKET_SIZE
+#endif
+
 #define USBTTY_DEVICE_CLASS	COMMUNICATIONS_DEVICE_CLASS
 
 #define USBTTY_BCD_DEVICE	0x00
drivers/usb/gadget/core.c +0 -1
index 4f2ebab..46ab3f6 100644
@@ -212,7 +212,6 @@ struct usb_device_descriptor *usbd_device_device_descriptor (struct usb_device_i
 	return (device->device_descriptor);
 }
 
-
 /**
  * usbd_device_configuration_descriptor
  * @device: which device
drivers/usb/gadget/ep0.c +19 -4
index 22499d3..aa8f916 100644
@@ -338,12 +338,27 @@ static int ep0_get_descriptor (struct usb_device_instance *device,
 		}
 		break;
 	case USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
+#if defined(CONFIG_USBD_HS)
 		{
-			/* If a USB device supports both a full speed and low speed operation
-			 * we must send a Device_Qualifier descriptor here
-			 */
-			return -1;
+			struct usb_qualifier_descriptor *qualifier_descriptor =
+				device->qualifier_descriptor;
+
+			if (!qualifier_descriptor)
+				return -1;
+
+			/* copy descriptor for this device */
+			copy_config(urb, qualifier_descriptor,
+					sizeof(struct usb_qualifier_descriptor),
+					max);
+
 		}
+		dbg_ep0(3, "copied qualifier descriptor, actual_length: 0x%x",
+				urb->actual_length);
+#else
+		return -1;
+#endif
+		break;
+
 	default:
 		return -1;
 	}
include/usbdescriptors.h +15 -0
index 2dec3b9..de1069f 100644
@@ -241,6 +241,21 @@ struct usb_device_descriptor {
 	u8 bNumConfigurations;
 } __attribute__ ((packed));
 
+#if defined(CONFIG_USBD_HS)
+struct usb_qualifier_descriptor {
+	u8 bLength;
+	u8 bDescriptorType;
+
+	u16 bcdUSB;
+	u8 bDeviceClass;
+	u8 bDeviceSubClass;
+	u8 bDeviceProtocol;
+	u8 bMaxPacketSize0;
+	u8 bNumConfigurations;
+	u8 breserved;
+} __attribute__ ((packed));
+#endif
+
 struct usb_string_descriptor {
 	u8 bLength;
 	u8 bDescriptorType;	/* 0x03 */
include/usbdevice.h +21 -1
index 9eb8849..7037efd 100644
@@ -210,6 +210,10 @@ struct usb_bus_instance;
 #define USB_DT_INTERFACE		0x04
 #define USB_DT_ENDPOINT			0x05
 
+#if defined(CONFIG_USBD_HS)
+#define USB_DT_QUAL			0x06
+#endif
+
 #define USB_DT_HID			(USB_TYPE_CLASS | 0x01)
 #define USB_DT_REPORT			(USB_TYPE_CLASS | 0x02)
 #define USB_DT_PHYSICAL			(USB_TYPE_CLASS | 0x03)
@@ -291,7 +295,11 @@ struct usb_bus_instance;
  * USB Spec Release number
  */
 
+#if defined(CONFIG_USBD_HS)
+#define USB_BCD_VERSION			0x0200
+#else
 #define USB_BCD_VERSION			0x0110
+#endif
 
 
 /*
@@ -567,6 +575,9 @@ struct usb_device_instance {
 	/* generic */
 	char *name;
 	struct usb_device_descriptor *device_descriptor;	/* per device descriptor */
+#if defined(CONFIG_USBD_HS)
+	struct usb_qualifier_descriptor *qualifier_descriptor;
+#endif
 
 	void (*event) (struct usb_device_instance *device, usb_device_event_t event, int data);
 
@@ -659,8 +670,17 @@ struct usb_class_report_descriptor *usbd_device_class_report_descriptor_index( s
 struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor (struct usb_device_instance *, int, int, int, int, int);
 int				usbd_device_endpoint_transfersize (struct usb_device_instance *, int, int, int, int, int);
 struct usb_string_descriptor *usbd_get_string (u8);
-struct usb_device_descriptor *usbd_device_device_descriptor (struct usb_device_instance *, int);
+struct usb_device_descriptor *usbd_device_device_descriptor(struct
+		usb_device_instance *, int);
 
+#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
+ * Retuns FALSE otherwise
+ */
+int is_usbd_high_speed(void);
+#endif
 int usbd_endpoint_halted (struct usb_device_instance *device, int endpoint);
 void usbd_rcv_complete(struct usb_endpoint_instance *endpoint, int len, int urb_bad);
 void usbd_tx_complete (struct usb_endpoint_instance *endpoint);
Signature · 1 line
1.7.2.2
#1 lore raw

PATCH v2 1/1 Enable high speed support for USB device framework and usbtty

Dear Amit Virdi,

Quoted 7 lines

From: Vipin KUMAR <[email protected]>

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.

Quoted 6 lines

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)"

Applied and pushed,thanks for your good work folks!

Also, please forgive me for my long response time!

Best regards,
Marek Vasut