Skip to contentSkip to conversation

usb: gadget: fastboot: make high-speed work

PATCH New Matt Reimer 3 participants 3 messages Feb 19, 2015 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: fastboot: make high-speed work

Make fastboot work in high-speed mode by specifying separate sets of usb_descriptor_headers for full-speed and high-speed.

Tested on s5p_ds5.

---
 drivers/usb/gadget/f_fastboot.c |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/usb/gadget/f_fastboot.c +24 -3
index 310175a..024ef20 100644
@@ -74,6 +74,15 @@ static struct usb_endpoint_descriptor fs_ep_out = {
 	.bInterval		= 0x00,
 };
 
+static struct usb_endpoint_descriptor hs_ep_in = {
+	.bLength		= USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType	= USB_DT_ENDPOINT,
+	.bEndpointAddress	= USB_DIR_IN,
+	.bmAttributes		= USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize		= RX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0,
+	.bInterval		= 0x00,
+};
+
 static struct usb_endpoint_descriptor hs_ep_out = {
 	.bLength		= USB_DT_ENDPOINT_SIZE,
 	.bDescriptorType	= USB_DT_ENDPOINT,
@@ -94,9 +103,16 @@ static struct usb_interface_descriptor interface_desc = {
 	.bInterfaceProtocol	= FASTBOOT_INTERFACE_PROTOCOL,
 };
 
-static struct usb_descriptor_header *fb_runtime_descs[] = {
+static struct usb_descriptor_header *fb_fs_runtime_descs[] = {
 	(struct usb_descriptor_header *)&interface_desc,
 	(struct usb_descriptor_header *)&fs_ep_in,
+	(struct usb_descriptor_header *)&fs_ep_out,
+	NULL,
+};
+
+static struct usb_descriptor_header *fb_hs_runtime_descs[] = {
+	(struct usb_descriptor_header *)&interface_desc,
+	(struct usb_descriptor_header *)&hs_ep_in,
 	(struct usb_descriptor_header *)&hs_ep_out,
 	NULL,
 };
@@ -160,6 +176,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
 	f_fb->out_ep->driver_data = c->cdev;
 
 	hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
+	hs_ep_in.bEndpointAddress = fs_ep_in.bEndpointAddress;
 
 	return 0;
 }
@@ -236,7 +253,10 @@ static int fastboot_set_alt(struct usb_function *f,
 	}
 	f_fb->out_req->complete = rx_handler_command;
 
-	ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in);
+	if (gadget->speed == USB_SPEED_HIGH)
+		ret = usb_ep_enable(f_fb->in_ep, &hs_ep_in);
+	else
+		ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in);
 	if (ret) {
 		puts("failed to enable in ep\n");
 		goto err;
@@ -277,7 +297,8 @@ static int fastboot_add(struct usb_configuration *c)
 	}
 
 	f_fb->usb_function.name = "f_fastboot";
-	f_fb->usb_function.hs_descriptors = fb_runtime_descs;
+	f_fb->usb_function.descriptors = fb_fs_runtime_descs;
+	f_fb->usb_function.hs_descriptors = fb_hs_runtime_descs;
 	f_fb->usb_function.bind = fastboot_bind;
 	f_fb->usb_function.unbind = fastboot_unbind;
 	f_fb->usb_function.set_alt = fastboot_set_alt;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 usb: gadget: fastboot: make high-speed work

Quoted 6 lines · Matt Reimer

Make fastboot work in high-speed mode by specifying separate sets of usb_descriptor_headers for full-speed and high-speed.

Tested on s5p_ds5.

Hi,

looks good. Please keep Lukasz on CC, since he's the USB gadget guru.

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/1 usb: gadget: fastboot: make high-speed work

In reply to Matt Reimer

Hi Matt:

Quoted 17 lines · Matt Reimer

Make fastboot work in high-speed mode by specifying separate sets of usb_descriptor_headers for full-speed and high-speed.

Tested on s5p_ds5.

---
  drivers/usb/gadget/f_fastboot.c |   27 ++++++++++++++++++++++++---
  1 file changed, 24 insertions(+), 3 deletions(-)
drivers/usb/gadget/f_fastboot.c +0 -0
index 310175a..024ef20 100644
@@ -74,6 +74,15 @@ static struct usb_endpoint_descriptor fs_ep_out = {
  	.bInterval		= 0x00,
  };

drivers/usb/gadget/f_fastboot.c static struct usb_endpoint_descriptor fs_ep_out = { · line 85

Quoted 10 lines
drivers/usb/gadget/f_fastboot.c +9 -0
 
+static struct usb_endpoint_descriptor hs_ep_in = {
+	.bLength		= USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType	= USB_DT_ENDPOINT,
+	.bEndpointAddress	= USB_DIR_IN,
+	.bmAttributes		= USB_ENDPOINT_XFER_BULK,
+	.wMaxPacketSize		= RX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0,
+	.bInterval		= 0x00,
+};
+

Are you certain that you have the "in" and "out" correct? Looking at the three existing "usb_endpoint_descriptors"
fs_ep_in
fs_ep_out
hs_ep_out
The "in" is for sending data from the device TO the host, and the "out" is for receiving data FROM the host.
The maximum packet size changes between 1.1 and 2.0 for receiving packets (on the "out" endpoint), but AFAIK the maximum packet size is the same for 1.1 and 2.0 (hence the fs_ep_in is used for both fs AND hs).... This change suggests that the maximum packet size for sending packets TO the host has changed as well - if it has, then the define in hs_ep_in (above) needs to be:
.wMaxPacketSize = TX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0,
in order to avoid confusion....
Thanks, Steve

Quoted 52 lines
drivers/usb/gadget/f_fastboot.c +15 -3
  static struct usb_endpoint_descriptor hs_ep_out = {
  	.bLength		= USB_DT_ENDPOINT_SIZE,
  	.bDescriptorType	= USB_DT_ENDPOINT,
@@ -94,9 +103,16 @@ static struct usb_interface_descriptor interface_desc = {
  	.bInterfaceProtocol	= FASTBOOT_INTERFACE_PROTOCOL,
  };
 
-static struct usb_descriptor_header *fb_runtime_descs[] = {
+static struct usb_descriptor_header *fb_fs_runtime_descs[] = {
  	(struct usb_descriptor_header *)&interface_desc,
  	(struct usb_descriptor_header *)&fs_ep_in,
+	(struct usb_descriptor_header *)&fs_ep_out,
+	NULL,
+};
+
+static struct usb_descriptor_header *fb_hs_runtime_descs[] = {
+	(struct usb_descriptor_header *)&interface_desc,
+	(struct usb_descriptor_header *)&hs_ep_in,
  	(struct usb_descriptor_header *)&hs_ep_out,
  	NULL,
  };
@@ -160,6 +176,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
  	f_fb->out_ep->driver_data = c->cdev;
 
  	hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
+	hs_ep_in.bEndpointAddress = fs_ep_in.bEndpointAddress;
 
  	return 0;
  }
@@ -236,7 +253,10 @@ static int fastboot_set_alt(struct usb_function *f,
  	}
  	f_fb->out_req->complete = rx_handler_command;
 
-	ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in);
+	if (gadget->speed == USB_SPEED_HIGH)
+		ret = usb_ep_enable(f_fb->in_ep, &hs_ep_in);
+	else
+		ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in);
  	if (ret) {
  		puts("failed to enable in ep\n");
  		goto err;
@@ -277,7 +297,8 @@ static int fastboot_add(struct usb_configuration *c)
  	}
 
  	f_fb->usb_function.name = "f_fastboot";
-	f_fb->usb_function.hs_descriptors = fb_runtime_descs;
+	f_fb->usb_function.descriptors = fb_fs_runtime_descs;
+	f_fb->usb_function.hs_descriptors = fb_hs_runtime_descs;
  	f_fb->usb_function.bind = fastboot_bind;
  	f_fb->usb_function.unbind = fastboot_unbind;
  	f_fb->usb_function.set_alt = fastboot_set_alt;