diff mbox series

[U-Boot,07/14] usb: Read device descriptor after device is addressed for xHCI

Message ID 1505742050-5697-8-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Marek Vasut
Headers show
Series usb: xhci: Add interrupt transfer support and full speed device support | expand

Commit Message

Bin Meng Sept. 18, 2017, 1:40 p.m. UTC
For xHCI it is not possible to read a device descriptor before it
has been assigned an address. That's why usb_setup_descriptor()
was called with 'do_read' being false. But we really need try to
read the device descriptor before starting any real communication
with the default control endpoint.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 common/usb.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Stefan Roese Sept. 22, 2017, 5:01 a.m. UTC | #1
On 18.09.2017 15:40, Bin Meng wrote:
> For xHCI it is not possible to read a device descriptor before it
> has been assigned an address. That's why usb_setup_descriptor()
> was called with 'do_read' being false. But we really need try to
> read the device descriptor before starting any real communication
> with the default control endpoint.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
> 
>   common/usb.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/common/usb.c b/common/usb.c
> index 88cee81..8d27bc7 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -1052,6 +1052,17 @@ static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read,
>   
>   	mdelay(10);	/* Let the SET_ADDRESS settle */
>   
> +	/*
> +	 * If we haven't read device descriptor before, read it here
> +	 * after device is assigned an address. This is only applicable
> +	 * to xHCI so far.
> +	 */
> +	if (!do_read) {
> +		err = usb_setup_descriptor(dev, true);
> +		if (err)
> +			return err;
> +	}
> +
>   	return 0;
>   }
>   
> 

Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
diff mbox series

Patch

diff --git a/common/usb.c b/common/usb.c
index 88cee81..8d27bc7 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1052,6 +1052,17 @@  static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read,
 
 	mdelay(10);	/* Let the SET_ADDRESS settle */
 
+	/*
+	 * If we haven't read device descriptor before, read it here
+	 * after device is assigned an address. This is only applicable
+	 * to xHCI so far.
+	 */
+	if (!do_read) {
+		err = usb_setup_descriptor(dev, true);
+		if (err)
+			return err;
+	}
+
 	return 0;
 }