From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Rae Date: Thu, 19 Feb 2015 11:20:10 -0800 Subject: [U-Boot] [PATCH] usb: gadget: fastboot: make high-speed work In-Reply-To: <1424370340-63530-1-git-send-email-mreimer@sdgsystems.com> References: <1424370340-63530-1-git-send-email-mreimer@sdgsystems.com> Message-ID: <54E6376A.9000809@broadcom.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Matt: On 15-02-19 10:25 AM, Matt Reimer wrote: > 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. > > Signed-off-by: Matt Reimer > --- > drivers/usb/gadget/f_fastboot.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c > index 310175a..024ef20 100644 > --- a/drivers/usb/gadget/f_fastboot.c > +++ b/drivers/usb/gadget/f_fastboot.c > @@ -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, > +}; > + 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 > 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; >