From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Fri, 18 Dec 2015 03:35:46 +0100 Subject: [U-Boot] [PATCH] usb: Move determination of TT hub address/port into seperate function In-Reply-To: <1450401101-22591-1-git-send-email-stefan.bruens@rwth-aachen.de> References: <3364487.y0b5h7sQeW@pebbles.site> <1450401101-22591-1-git-send-email-stefan.bruens@rwth-aachen.de> Message-ID: <201512180335.46420.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday, December 18, 2015 at 02:11:41 AM, Stefan Br?ns wrote: > Start split and complete split tokens need the hub address and the > downstream port of the first HS hub (device view). > > The core of the function was duplicated in both host/ehci_hcd and > musb-new/usb-compat.h. > > Signed-off-by: Stefan Br?ns > --- > Obsoletes [PATCH 3/6] usb: dwc2: determine TT hub address and port for > split transactions > > common/usb.c | 54 > +++++++++++++++++++++++++++++++++++++++ drivers/usb/host/ehci-hcd.c > | 50 ++++-------------------------------- drivers/usb/musb-new/musb_host.c > | 8 +++--- > drivers/usb/musb-new/usb-compat.h | 53 > -------------------------------------- include/usb.h | > 10 ++++++++ > 5 files changed, 74 insertions(+), 101 deletions(-) > > diff --git a/common/usb.c b/common/usb.c > index 700bfc3..1d0a151 100644 > --- a/common/usb.c > +++ b/common/usb.c > @@ -1200,4 +1200,58 @@ bool usb_device_has_child_on_port(struct usb_device > *parent, int port) #endif > } > > +#ifdef CONFIG_DM_USB > +void usb_find_hub_address_port(struct usb_device *udev, > + uint8_t *hub_address, uint8_t *hub_port) > +{ > + struct udevice *parent; > + struct usb_device *uparent, *ttdev; > + > + /* > + * When called from usb-uclass.c: usb_scan_device() udev->dev points > + * to the parent udevice, not the actual udevice belonging to the > + * udev as the device is not instantiated yet. So when searching > + * for the first usb-2 parent start with udev->dev not > + * udev->dev->parent . > + */ > + ttdev = udev; > + parent = udev->dev; > + uparent = dev_get_parent_priv(parent); > + > + while (uparent->speed != USB_SPEED_HIGH) { > + struct udevice *dev = parent; > + > + if (device_get_uclass_id(dev->parent) != UCLASS_USB_HUB) { > + printf("Error: Cannot find high speed parent of usb-1 device\n"); > + *hub_address = *hub_port = 0; Please avoid this construct: foo = bar = 1234; , it's really confusing and error prone. Otherwise looks good! Reviewed-by: Marek Vasut