usb: cmd: Print actual packet size for super speed devices
authorBin Meng <bmeng.cn@gmail.com>
Wed, 19 Jul 2017 13:50:07 +0000 (21:50 +0800)
committerMarek Vasut <marex@denx.de>
Fri, 28 Jul 2017 21:34:25 +0000 (23:34 +0200)
USB 3.0 defines bMaxPacketSize0 field in the device descriptor as
the exponent of 2, so let's print the calculated actual size.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
cmd/usb.c

index 4fa456e318347452785edf5a2239fda63a1a6458..992d41408191c8fa20445a378ba80148850f8fde 100644 (file)
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -150,6 +150,8 @@ static void usb_display_string(struct usb_device *dev, int index)
 
 static void usb_display_desc(struct usb_device *dev)
 {
+       uint packet_size = dev->descriptor.bMaxPacketSize0;
+
        if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
                printf("%d: %s,  USB Revision %x.%x\n", dev->devnum,
                usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass),
@@ -171,9 +173,10 @@ static void usb_display_desc(struct usb_device *dev)
                               usb_get_class_desc(
                                dev->config.if_desc[0].desc.bInterfaceClass));
                }
+               if (dev->descriptor.bcdUSB >= cpu_to_le16(0x0300))
+                       packet_size = 1 << packet_size;
                printf(" - PacketSize: %d  Configurations: %d\n",
-                       dev->descriptor.bMaxPacketSize0,
-                       dev->descriptor.bNumConfigurations);
+                       packet_size, dev->descriptor.bNumConfigurations);
                printf(" - Vendor: 0x%04x  Product 0x%04x Version %d.%d\n",
                        dev->descriptor.idVendor, dev->descriptor.idProduct,
                        (dev->descriptor.bcdDevice>>8) & 0xff,