Message ID | CAJMWnChDAHAWP+PrPb-XQxmENnobS4=t_WkOikf2P-aBX2XA4w@mail.gmail.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=RCgDdxsZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F0rtf0Kj5z9sVb for <incoming@patchwork.ozlabs.org>; Thu, 18 Mar 2021 00:42:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D43EB82807; Wed, 17 Mar 2021 14:42:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RCgDdxsZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF282826F2; Wed, 17 Mar 2021 14:25:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2114082652 for <u-boot@lists.denx.de>; Wed, 17 Mar 2021 14:25:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=joaofl@gmail.com Received: by mail-yb1-xb2b.google.com with SMTP id f145so24084536ybg.11 for <u-boot@lists.denx.de>; Wed, 17 Mar 2021 06:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=FhD34am27E+LQQcKhzoO4Aio9VqYr44fEThwW8iY4fc=; b=RCgDdxsZIb6reFG5uyLwFbIztk68Jm5sVE0DKTsyVvxsCNPl+rMmdRWTucbJJ8ONZE oTa8xTMP5S2eOrHthVj6GkOTXV60L3Hcm2F6GolKaHxHSv/sCciwCs/UPydeUXIh8rKi IVBICocFhV6RahInpB5/Z3XFU9XztRPadtwDeWEsVi34fNFI5/M80i7+TGhVjiV/W+c6 hWFGO4wdKYVg/tJvqGuntcHIvYp1f+ezptwFOJzt9hMKTgUYhgaZIRz81CrGGzllmjOu Xm7HKWeSMggHjFKvBsXB8dOBRPhjOk9V/Pq7YSYjkVZ0cfVJn0CQOMyBCwa2q6UEGRSw TqLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=FhD34am27E+LQQcKhzoO4Aio9VqYr44fEThwW8iY4fc=; b=Jz8/0xZalP+ouhY6VY+Uil/M34eXPH2kV6Y2FvYBb2oO9GKZ17pnJGjXZ/6gVX106N gFWmw6yutc+bhVlLxgItfHXCdWNPDQQE3fzQr0HJPHSmFelIXCxQKvtuTTVp8TkJwFjm fetUNgwr6k6GohdNsJKmJ0TdMUEKqtraTOVLOI5MfA2CnWjs+a8DXtgaOlQDsKPptADR UdkxGhsJ/5fz6J9MDUiUi7+UUYBjbXFOOhPe2EyYcWidL5yNOgaL1bH+zvuvvsyzyc/1 UKjF6NbHKHZJRQcpAlhHJlgSlhGnnGyJaPH92kaQdogBYKYxVz/qz/Wn5xPgy8TZHgS4 JI5Q== X-Gm-Message-State: AOAM532vYFuOGlA2D36Q+qYNUpi00fgwq4Zue7qSRIuuRPzoKCPI8lxi DC68QSgn3BPHVOo5wES2W1k4srZzTfAm/ZMPxPakHs8j X-Google-Smtp-Source: ABdhPJwYycaS77pYr0X1tIw2q0s9e5TAsgo2FfAVm6eK7YRgtiYZph6D1wxeV8zGdNghMdLii2eYV4pyGPv9mqK4Adc= X-Received: by 2002:a25:1e82:: with SMTP id e124mr4244250ybe.98.1615987511917; Wed, 17 Mar 2021 06:25:11 -0700 (PDT) MIME-Version: 1.0 References: <CAJMWnChnVRL1N24RHhs-eUF1niyEKGVAsuReovvnYvy8Xjw4sw@mail.gmail.com> In-Reply-To: <CAJMWnChnVRL1N24RHhs-eUF1niyEKGVAsuReovvnYvy8Xjw4sw@mail.gmail.com> From: =?utf-8?q?Jo=C3=A3o_Loureiro?= <joaofl@gmail.com> Date: Wed, 17 Mar 2021 14:24:35 +0100 Message-ID: <CAJMWnChDAHAWP+PrPb-XQxmENnobS4=t_WkOikf2P-aBX2XA4w@mail.gmail.com> Subject: [PATCH] Avoid delay when initializing USB peripherals by dwc2 To: u-boot@lists.denx.de Cc: marex@denx.de, l.majewski@samsung.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Wed, 17 Mar 2021 14:42:11 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean |
Series |
Avoid delay when initializing USB peripherals by dwc2
|
expand
|
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index ec643e9f45..7990060f3c 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -21,6 +21,7 @@ #include <asm/io.h> #include <dm/device_compat.h> #include <linux/delay.h> +#include <linux/usb/otg.h> #include <power/regulator.h> #include <reset.h> @@ -1204,7 +1205,13 @@ static int dwc2_init_common(struct udevice
When `usb start` is called, the dwc2 driver will try to start every USB device as host first, even if it is explicitly configured as peripheral in the device tree, as the documentation explains (`dr_mode = "peripheral"`). So to avoid an unwanted 15 seconds delay when initializing the usb (one second per channel = 1s x 15), this patch adds a check to the initialization, and will skip a host initialization of the device, when it is explicitly set as peripheral. The checking is already done similarly in the `drivers/usb/gadget/dwc2_udc_otg.c` driver. An example device tree entry: &usb0 { compatible = "snps,dwc2"; status = "okay"; dr_mode = "peripheral"; }; Signed-off-by: João Loureiro <joaofl@gmail.com> --- drivers/usb/host/dwc2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) *dev, struct dwc2_priv *priv) #endif dwc_otg_core_init(dev); - dwc_otg_core_host_init(dev, regs); + + if (usb_get_dr_mode(dev_ofnode(dev)) == USB_DR_MODE_PERIPHERAL) { + dev_dbg(dev, "USB device %s dr_mode set to %d. Skipping host_init.\n",\ + dev->name, usb_get_dr_mode(dev_ofnode(dev))); + } else { + dwc_otg_core_host_init(dev, regs); + } clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |