[U-Boot] [PATCH v2 1/3] usb: hub: identify the hub-device to usb_hub_reset_devices

Dr. Philipp Tomsich philipp.tomsich at theobroma-systems.com
Wed Nov 22 16:02:54 UTC 2017


> On 22 Nov 2017, at 16:59, Marek Vasut <marex at denx.de> wrote:
> 
> On 11/22/2017 04:57 PM, Philipp Tomsich wrote:
>> When usb_hub_reset_devices is called, it should be passed both an
>> indicator which hub it should operate on and what port number (local
>> to that hub) should be reset.
> 
> Why ?

Simply because there will be multiple root hubs in the system, which may
have multiple hubs attached.  And the usb_hub_reset_devices() function
was being called for every hub with just a port-number, but without the
context of what number-space (i.e. hub) that port-number belonged to.

The code in usb_hub previously was:
        /*
         * Reset any devices that may be in a bad state when applying
         * the power.  This is a __weak function.  Resetting of the devices
         * should occur in the board file of the device.
         */
        for (i = 0; i < dev->maxchild; i++)
                usb_hub_reset_devices(i + 1);

So it would call usb_hub_reset_devices(1) for the first port of every
attached hub (including the root-hubs).

I.e. the implementation of usb_hub_reset_devices had no idea what
(hub, port)-combination it was dealing with...

> 
>> This adds an additional 'hub' parameter to usb_hub_reset_devices.
>> Existing implementations are changed to simply ignore the new
>> parameter.
>> 
>> Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
>> 
>> ---
>> 
>> Changes in v2:
>> - new in v2
>> 
>> board/compulab/cm_t54/cm_t54.c | 2 +-
>> board/ti/omap5_uevm/evm.c      | 2 +-
>> common/usb_hub.c               | 4 ++--
>> 3 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/board/compulab/cm_t54/cm_t54.c b/board/compulab/cm_t54/cm_t54.c
>> index 31730a4..3e6235a 100644
>> --- a/board/compulab/cm_t54/cm_t54.c
>> +++ b/board/compulab/cm_t54/cm_t54.c
>> @@ -246,7 +246,7 @@ int ehci_hcd_stop(void)
>> 	return ret;
>> }
>> 
>> -void usb_hub_reset_devices(int port)
>> +void usb_hub_reset_devices(struct usb_hub_device *hub, int port)
>> {
>> 	/* The LAN9730 needs to be reset after the port power has been set. */
>> 	if (port == 3) {
>> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
>> index 4b25cc2..67242f5 100644
>> --- a/board/ti/omap5_uevm/evm.c
>> +++ b/board/ti/omap5_uevm/evm.c
>> @@ -249,7 +249,7 @@ int ehci_hcd_stop(void)
>> 	return omap_ehci_hcd_stop();
>> }
>> 
>> -void usb_hub_reset_devices(int port)
>> +void usb_hub_reset_devices(struct usb_hub_device *hub, int port)
>> {
>> 	/* The LAN9730 needs to be reset after the port power has been set. */
>> 	if (port == 3) {
>> diff --git a/common/usb_hub.c b/common/usb_hub.c
>> index 325d16d..024dadb 100644
>> --- a/common/usb_hub.c
>> +++ b/common/usb_hub.c
>> @@ -57,7 +57,7 @@ struct usb_device_scan {
>> 
>> static LIST_HEAD(usb_scan_list);
>> 
>> -__weak void usb_hub_reset_devices(int port)
>> +__weak void usb_hub_reset_devices(struct usb_hub_device *hub, int port)
>> {
>> 	return;
>> }
>> @@ -853,7 +853,7 @@ static int usb_hub_configure(struct usb_device *dev)
>> 	 * should occur in the board file of the device.
>> 	 */
>> 	for (i = 0; i < dev->maxchild; i++)
>> -		usb_hub_reset_devices(i + 1);
>> +		usb_hub_reset_devices(hub, i + 1);
>> 
>> 	/*
>> 	 * Only add the connected USB devices, including potential hubs,
>> 
> 
> 
> -- 
> Best regards,
> Marek Vasut



More information about the U-Boot mailing list