From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/2] usb: Move determination of TT hub address/port into separate function
Date: Thu, 31 Dec 2015 16:16:10 +0100 [thread overview]
Message-ID: <201512311616.10808.marex@denx.de> (raw)
In-Reply-To: <1450743664-8612-1-git-send-email-stefan.bruens@rwth-aachen.de>
On Tuesday, December 22, 2015 at 01:21:03 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 <stefan.bruens@rwth-aachen.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Tested-by: Hans de Goede <hdegoede@redhat.com>
> ---
> v2: - renamed function to usb_find_usb2_hub_address_port()
> - put musb port numbering change into separate patch
> v3: - do one assignment per line
> v4: - fix error in musb code (udev => urb->dev)
> - added Reviewed-by: et al
>
> common/usb.c | 56
> +++++++++++++++++++++++++++++++++++++++ drivers/usb/host/ehci-hcd.c
> | 50 ++++------------------------------ drivers/usb/musb-new/musb_host.c
> | 10 ++++---
> drivers/usb/musb-new/usb-compat.h | 53
> ------------------------------------ include/usb.h |
> 12 +++++++++
> 5 files changed, 80 insertions(+), 101 deletions(-)
>
> diff --git a/common/usb.c b/common/usb.c
> index b177391..9f67cc1 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -1214,4 +1214,60 @@ bool usb_device_has_child_on_port(struct usb_device
> *parent, int port) #endif
> }
>
> +#ifdef CONFIG_DM_USB
> +void usb_find_usb2_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 = 0;
> + *hub_port = 0;
> + return;
> + }
> +
> + ttdev = dev_get_parent_priv(dev);
> + parent = dev->parent;
> + uparent = dev_get_parent_priv(parent);
> + }
> + *hub_address = uparent->devnum;
> + *hub_port = ttdev->portnr;
> +}
> +#else
> +void usb_find_usb2_hub_address_port(struct usb_device *udev,
> + uint8_t *hub_address, uint8_t *hub_port)
> +{
> + /* Find out the nearest parent which is high speed */
> + while (udev->parent->parent != NULL)
> + if (udev->parent->speed != USB_SPEED_HIGH) {
> + udev = udev->parent;
> + } else {
> + *hub_address = udev->parent->devnum;
> + *hub_port = udev->portnr;
> + return;
> + }
> +
> + printf("Error: Cannot find high speed parent of usb-1 device\n");
> + *hub_address = 0;
> + *hub_port = 0;
> +}
> +#endif
> +
> +
> /* EOF */
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index c85dbce..af025de 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -279,56 +279,16 @@ static inline u8 ehci_encode_speed(enum
> usb_device_speed speed) static void ehci_update_endpt2_dev_n_port(struct
> usb_device *udev, struct QH *qh)
> {
> - struct usb_device *ttdev;
> - int parent_devnum;
> + uint8_t portnr = 0;
> + uint8_t hubaddr = 0;
>
> if (udev->speed != USB_SPEED_LOW && udev->speed != USB_SPEED_FULL)
> return;
>
> - /*
> - * For full / low speed devices we need to get the devnum and portnr of
> - * the tt, so of the first upstream usb-2 hub, there may be usb-1 hubs
> - * in the tree before that one!
> - */
> -#ifdef CONFIG_DM_USB
> - /*
> - * 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 .
> - */
> - struct udevice *parent;
> - struct usb_device *uparent;
> -
> - 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("ehci: Error cannot find high-speed parent of
usb-1 device\n");
> - return;
> - }
> -
> - ttdev = dev_get_parent_priv(dev);
> - parent = dev->parent;
> - uparent = dev_get_parent_priv(parent);
> - }
> - parent_devnum = uparent->devnum;
> -#else
> - ttdev = udev;
> - while (ttdev->parent && ttdev->parent->speed != USB_SPEED_HIGH)
> - ttdev = ttdev->parent;
> - if (!ttdev->parent)
> - return;
> - parent_devnum = ttdev->parent->devnum;
> -#endif
> + usb_find_usb2_hub_address_port(udev, &hubaddr, &portnr)
Please compile-test your patches, there's a missing ; .
prev parent reply other threads:[~2015-12-31 15:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 0:21 [U-Boot] [PATCH v4 1/2] usb: Move determination of TT hub address/port into separate function Stefan Brüns
2015-12-22 0:21 ` [U-Boot] [PATCH v4 2/2] usb: musb: Fix hub port setting for SPLIT transactions Stefan Brüns
2015-12-22 0:24 ` Marek Vasut
2015-12-31 15:16 ` Marek Vasut [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201512311616.10808.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.