From patchwork Sun May 10 12:10:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 470443 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BA9711401DA for ; Sun, 10 May 2015 22:12:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D21634B689; Sun, 10 May 2015 14:11:47 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j-nhQgG4sCZv; Sun, 10 May 2015 14:11:47 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0FF034B639; Sun, 10 May 2015 14:11:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 64A0D4B6AF for ; Sun, 10 May 2015 14:10:59 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GZnhaA0G9Mit for ; Sun, 10 May 2015 14:10:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 0187B4B689 for ; Sun, 10 May 2015 14:10:51 +0200 (CEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4ACAgBO001268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 10 May 2015 08:10:43 -0400 Received: from shalem.localdomain.com (vpn1-5-196.ams2.redhat.com [10.36.5.196]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4ACASp6008549; Sun, 10 May 2015 08:10:41 -0400 From: Hans de Goede To: Simon Glass , Marek Vasut Date: Sun, 10 May 2015 14:10:20 +0200 Message-Id: <1431259827-8109-9-git-send-email-hdegoede@redhat.com> In-Reply-To: <1431259827-8109-1-git-send-email-hdegoede@redhat.com> References: <1431259827-8109-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: u-boot@lists.denx.de, Ian Campbell Subject: [U-Boot] [PATCH v5 08/15] dm: usb: Add support for companion controllers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" USB companion controllers must be scanned after the main controller has been scanned, so that any devices which the main controller which to hand over to the companion have actually been handed over before we scan the companion. As there are no guarantees that this will magically happen in the right order, split the scanning of the buses in 2 phases, first main controllers, and then companion controllers. Signed-off-by: Hans de Goede Acked-by: Simon Glass --- drivers/usb/host/usb-uclass.c | 33 ++++++++++++++++++++++++++++----- include/usb.h | 3 +++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index ad778b4..749257c 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -171,6 +171,7 @@ static void usb_scan_bus(struct udevice *bus, bool recurse) int usb_init(void) { int controllers_initialized = 0; + struct usb_bus_priv *priv; struct udevice *bus; struct uclass *uc; int count = 0; @@ -198,15 +199,37 @@ int usb_init(void) printf("probe failed, error %d\n", ret); continue; } - /* - * lowlevel init is OK, now scan the bus for devices - * i.e. search HUBs and configure them - */ controllers_initialized++; - usb_scan_bus(bus, true); usb_started = true; } + /* + * lowlevel init done, now scan the bus for devices i.e. search HUBs + * and configure them, first scan primary controllers. + */ + uclass_foreach_dev(bus, uc) { + if (!device_active(bus)) + continue; + + priv = dev_get_uclass_priv(bus); + if (!priv->companion) + usb_scan_bus(bus, true); + } + + /* + * Now that the primary controllers have been scanned and have handed + * over any devices they do not understand to their companions, scan + * the companions. + */ + uclass_foreach_dev(bus, uc) { + if (!device_active(bus)) + continue; + + priv = dev_get_uclass_priv(bus); + if (priv->companion) + usb_scan_bus(bus, true); + } + debug("scan end\n"); /* if we were not able to find at least one working bus, bail out */ if (!count) diff --git a/include/usb.h b/include/usb.h index 609b13d..5043bc3 100644 --- a/include/usb.h +++ b/include/usb.h @@ -608,10 +608,13 @@ struct usb_dev_platdata { * @desc_before_addr: true if we can read a device descriptor before it * has been assigned an address. For XHCI this is not possible * so this will be false. + * @companion: True if this is a companion controller to another USB + * controller */ struct usb_bus_priv { int next_addr; bool desc_before_addr; + bool companion; }; /**