]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb.c
Merge branch 'tx51-bugfix' into karo-tx-merge
[karo-tx-uboot.git] / common / usb.c
index 50fa466b4a5933d2c8b52cc8c6a552362203acf7..f740e5ec219cbe42a8d7375ed582b277a2ebc50b 100644 (file)
@@ -1,5 +1,4 @@
 /*
- *
  * Most of this source has been derived from the Linux USB
  * project:
  * (C) Copyright Linus Torvalds 1999
  * Adapted for U-Boot:
  * (C) Copyright 2001 Denis Peter, MPL AG Switzerland
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -348,6 +330,7 @@ static int usb_parse_config(struct usb_device *dev,
        struct usb_descriptor_header *head;
        int index, ifno, epno, curr_if_num;
        u16 ep_wMaxPacketSize;
+       struct usb_interface *if_desc = NULL;
 
        ifno = -1;
        epno = -1;
@@ -375,23 +358,27 @@ static int usb_parse_config(struct usb_device *dev,
                             &buffer[index])->bInterfaceNumber != curr_if_num) {
                                /* this is a new interface, copy new desc */
                                ifno = dev->config.no_of_if;
+                               if_desc = &dev->config.if_desc[ifno];
                                dev->config.no_of_if++;
-                               memcpy(&dev->config.if_desc[ifno],
-                                       &buffer[index], buffer[index]);
-                               dev->config.if_desc[ifno].no_of_ep = 0;
-                               dev->config.if_desc[ifno].num_altsetting = 1;
+                               memcpy(if_desc, &buffer[index], buffer[index]);
+                               if_desc->no_of_ep = 0;
+                               if_desc->num_altsetting = 1;
                                curr_if_num =
-                                    dev->config.if_desc[ifno].desc.bInterfaceNumber;
+                                    if_desc->desc.bInterfaceNumber;
                        } else {
                                /* found alternate setting for the interface */
-                               dev->config.if_desc[ifno].num_altsetting++;
+                               if (ifno >= 0) {
+                                       if_desc = &dev->config.if_desc[ifno];
+                                       if_desc->num_altsetting++;
+                               }
                        }
                        break;
                case USB_DT_ENDPOINT:
                        epno = dev->config.if_desc[ifno].no_of_ep;
+                       if_desc = &dev->config.if_desc[ifno];
                        /* found an endpoint */
-                       dev->config.if_desc[ifno].no_of_ep++;
-                       memcpy(&dev->config.if_desc[ifno].ep_desc[epno],
+                       if_desc->no_of_ep++;
+                       memcpy(&if_desc->ep_desc[epno],
                                &buffer[index], buffer[index]);
                        ep_wMaxPacketSize = get_unaligned(&dev->config.\
                                                        if_desc[ifno].\
@@ -404,6 +391,11 @@ static int usb_parse_config(struct usb_device *dev,
                                        wMaxPacketSize);
                        debug("if %d, ep %d\n", ifno, epno);
                        break;
+               case USB_DT_SS_ENDPOINT_COMP:
+                       if_desc = &dev->config.if_desc[ifno];
+                       memcpy(&if_desc->ss_ep_comp_desc[epno],
+                               &buffer[index], buffer[index]);
+                       break;
                default:
                        if (head->bLength == 0)
                                return 1;
@@ -874,6 +866,11 @@ int usb_new_device(struct usb_device *dev)
        }
 
        dev->descriptor.bMaxPacketSize0 = desc->bMaxPacketSize0;
+       /*
+        * Fetch the device class, driver can use this info
+        * to differentiate between HUB and DEVICE.
+        */
+       dev->descriptor.bDeviceClass = desc->bDeviceClass;
 
        /* find the port number we're at */
        if (parent) {