All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stefan Brüns" <stefan.bruens@rwth-aachen.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] usb: dwc2: determine TT hub address and port for split transactions
Date: Sun, 13 Dec 2015 05:17:55 +0100	[thread overview]
Message-ID: <1449980278-19881-4-git-send-email-stefan.bruens@rwth-aachen.de> (raw)
In-Reply-To: <1449980278-19881-1-git-send-email-stefan.bruens@rwth-aachen.de>

Start split and complete split tokens need the hub address and the
downstream port of the first HS hub (device view).
Code copied from host/ehci_hcd.c

Signed-off-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
---
 drivers/usb/host/dwc2.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index db3acd4..2d97546 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -404,6 +404,66 @@ static void dwc_otg_core_init(struct dwc2_core_regs *regs)
 }
 
 /*
+ * Searches for the first HS hub above the given device. If a
+ * HS hub is found, the hub address and the port the device is
+ * connected to is return, as required for SPLIT transactions
+ *
+ * @param: udev full speed or low speed device
+ */
+#ifdef CONFIG_DM_USB
+static void dwc_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("dwc2: Error cannot find high speed parent of usb-1 device\n");
+			*hub_address = *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
+static void dwc_find_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("dwc2: Error cannot find high speed parent of usb-1 device\n");
+	*hub_address = *hub_port = 0;
+}
+#endif
+
+/*
  * Prepares a host channel for transferring packets to/from a specific
  * endpoint. The HCCHARn register is set up with the characteristics specified
  * in _hc. Host channel interrupts that may need to be serviced while this
-- 
2.1.4

  parent reply	other threads:[~2015-12-13  4:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-13  4:17 [U-Boot] [PATCH 0/6] usb: dwc2: add SPLIT transaction support Stefan Brüns
2015-12-13  4:17 ` [U-Boot] [PATCH 1/6] usb: dwc2: avoid out of bounds access Stefan Brüns
2015-12-13  4:41   ` Marek Vasut
2015-12-16  2:58   ` Stephen Warren
2015-12-16 10:29     ` Marek Vasut
2015-12-17  1:44       ` Stefan Bruens
2015-12-13  4:17 ` [U-Boot] [PATCH 2/6] usb: dwc2: Handle NAK during CONTROL DATA and STATUS stage Stefan Brüns
2015-12-13  4:46   ` Marek Vasut
2015-12-16  3:07   ` Stephen Warren
2015-12-17  3:09     ` Stefan Bruens
2015-12-13  4:17 ` Stefan Brüns [this message]
2015-12-13  4:43   ` [U-Boot] [PATCH 3/6] usb: dwc2: determine TT hub address and port for split transactions Marek Vasut
2015-12-16  3:17   ` Stephen Warren
2015-12-17  3:16     ` Stefan Bruens
2015-12-18  1:11       ` [U-Boot] [PATCH] usb: Move determination of TT hub address/port into seperate function Stefan Brüns
2015-12-18  2:35         ` Marek Vasut
2015-12-18 10:00         ` Hans de Goede
2015-12-19 17:17           ` Stefan Bruens
2015-12-19 18:27             ` Hans de Goede
2015-12-19 20:16               ` [U-Boot] [PATCH 1/2 v2] " Stefan Brüns
2015-12-19 20:16                 ` [U-Boot] [PATCH 2/2 v2] usb: musb: Fix hub port number for SPLIT transactions Stefan Brüns
2015-12-21 19:33                   ` Hans de Goede
2015-12-21 20:27                     ` Marek Vasut
2015-12-21 23:02                       ` Stefan Bruens
2015-12-21 23:08                         ` Marek Vasut
2015-12-19 20:26               ` [U-Boot] [PATCH 1/2 v3] usb: Move determination of TT hub address/port into seperate function Stefan Brüns
2015-12-20 19:12                 ` Hans de Goede
2015-12-21 19:32                   ` Hans de Goede
2015-12-13  4:17 ` [U-Boot] [PATCH 4/6] usb: dwc2: add helper function for setting SPLIT HC registers Stefan Brüns
2015-12-13  4:44   ` Marek Vasut
2015-12-16  3:19   ` Stephen Warren
2015-12-13  4:17 ` [U-Boot] [PATCH 5/6] usb: dwc2: add support for SPLIT transactions Stefan Brüns
2015-12-13  4:48   ` Marek Vasut
2015-12-16  3:36   ` Stephen Warren
2015-12-20  0:17     ` Stefan Bruens
2015-12-20  0:41       ` Marek Vasut
2015-12-13  4:17 ` [U-Boot] [PATCH 6/6] usb: dwc2: remove no longer used wait_for_chhltd() Stefan Brüns
2015-12-13  4:48   ` Marek Vasut
2015-12-16  3:36   ` Stephen Warren
2015-12-13  4:41 ` [U-Boot] [PATCH 0/6] usb: dwc2: add SPLIT transaction support Marek Vasut
2015-12-16  2:53 ` Stephen Warren

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=1449980278-19881-4-git-send-email-stefan.bruens@rwth-aachen.de \
    --to=stefan.bruens@rwth-aachen.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.