From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web11.3860.1591696744013233968 for ; Tue, 09 Jun 2020 02:59:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=2UC8ttBl; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.66, mailfrom: pete@akeo.ie) Received: by mail-wr1-f66.google.com with SMTP id h5so20578954wrc.7 for ; Tue, 09 Jun 2020 02:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jYY1mydT+rKtHdgcjxnHmkOZOYbYrcK1Dqg208WYREw=; b=2UC8ttBlO4//+Ntpi/XtTWnNmrRVtALnjjrZk4v/iGkSfY/AvMqQY48XYgZDNErqHB RAIiR9wZp/CwsQnRlKiE0hufm48owvM4P5NGI9BmyXgWdl/Px77tfo6dxeDG8/AuzQdV tqsE18QTaL2JFavwbalsDWwOY+iF2Tb2ishQd+woFGBbowgOPZPHqztABEO6+EZCDRhM Jcc8d5ORGDVnloIFFBtyjo+L9d6SbeGQj4L/pRnDbMXUZEyAfD1jhd5VQEg8n4M2lozA B1+rgN1Z7Hqeh5ThTHKb7DUTQ2RVP8cJI/Y6zJZsLg1BAs+rY0kI4mRtsIECtlLZbzMs F7wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jYY1mydT+rKtHdgcjxnHmkOZOYbYrcK1Dqg208WYREw=; b=XUYgEffJb+abV0whU9VK99vNQEWIuGk790vOyZuSuWNQBCAty/dUyBx4eLH1ScO/rj ar22ukq3LLPt78185p0xCQZJG4tGg2oJ0OTsNGQmF0jib/keR/rOE6gP8CGoqTueAIif 2sngNq4OvRV66uEwSlmzElfe4gGZlYrBk8NudaROBUDk3QIMv3AFYp5Q0Z76PDoOSq1D zJdwNSmMur9eFStmIur0Zfupkiu9C1kmiVmsYcaMjFOOf1vWUyNn0WDqE3SVXWDD5CTA Klr56BdYoDvSphy95Wx80H4wW4E9+NRA1VjhyLJBi9KBl1UKqyogk2pC6LwYpvezw1tN 3A3g== X-Gm-Message-State: AOAM5334gRCHJjG4AiSatAtdJT2mu3VVdJtdBlXxBwY7ZQEJ6Li2jP8T 96SnKYirqFd6kxXyjSKVyeBfn8FByh9PgA== X-Google-Smtp-Source: ABdhPJyJWyzWnD0MoGiW6x95ouesjGroPeNT4jiOF4wp0AV7w3P3eDHh/bSbISZXK5vB2vPe7t1y4w== X-Received: by 2002:adf:e44c:: with SMTP id t12mr3356984wrm.181.1591696742015; Tue, 09 Jun 2020 02:59:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.48.247]) by smtp.gmail.com with ESMTPSA id u13sm2721814wrp.53.2020.06.09.02.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2020 02:59:01 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com Subject: [edk2-platforms][PATCH 1/1] Platform/RaspberryPi: Ensure USB controller init before console Date: Tue, 9 Jun 2020 10:58:50 +0100 Message-Id: <20200609095850.3000-1-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Due to the nature of USB init on the Pi platforms, commit c8000ecccc83b728baf04ced2fedb870bc3bc1b3 introduced a regression with regards to ensuring that USB devices are operational by the time the console is up. This commit fixes this by adding explicit calls to connect USB controllers before console initialization. Note that trying to connect a non existent device (e.g. PCI bus on the Pi 3) is harmless so there's no need to guard these calls according to the devices effectively supported by the platform. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 31 ++++++++++++++++++++ Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 + 2 files changed, 32 insertions(+) diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c index 253614a646c1..d347c733855d 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c @@ -314,6 +314,30 @@ AddOutput ( ReportText)); } +/** + This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking + the matching driver to produce all first-level child handles. +**/ +STATIC +VOID +EFIAPI +Connect ( + IN EFI_HANDLE Handle, + IN CONST CHAR16 *ReportText + ) +{ + EFI_STATUS Status; + + Status = gBS->ConnectController ( + Handle, // ControllerHandle + NULL, // DriverImageHandle + NULL, // RemainingDevicePath -- produce all children + FALSE // Recursive + ); + DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n", + __FUNCTION__, ReportText, Status)); +} + STATIC INTN PlatformRegisterBootOption ( @@ -617,6 +641,13 @@ PlatformBootManagerBeforeConsole ( // Dispatch deferred images after EndOfDxe event and ReadyToLock installation. // EfiBootManagerDispatchDeferredImages (); + + // + // Ensure that USB is initialized by connecting the PCI root bridge so + // that the xHCI PCI controller gets enumerated (Pi 4) or by connecting + // to the DesignWare USB OTG controller directly. + FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect); + FilterAndProcess (&gEfiUsb2HcProtocolGuid, NULL, Connect); } /** diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index e40b3f096a4f..eb44daa4b7b7 100644 --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -78,6 +78,7 @@ [Protocols] gEfiDevicePathProtocolGuid gEfiGraphicsOutputProtocolGuid gEfiLoadedImageProtocolGuid + gEfiPciRootBridgeIoProtocolGuid gEfiSimpleFileSystemProtocolGuid gEsrtManagementProtocolGuid gEfiUsb2HcProtocolGuid -- 2.21.0.windows.1