Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F5C2C0015E for ; Fri, 28 Jul 2023 12:41:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 582F586900; Fri, 28 Jul 2023 14:41:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se 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=kwiboo.se header.i=@kwiboo.se header.b="hALBQ3gi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C88786650; Fri, 28 Jul 2023 14:40:26 +0200 (CEST) Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) (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 DE4FF868E8 for ; Fri, 28 Jul 2023 14:40:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=HqQocyA5y0CcLyt/8BZg19hAcVx8mMvgXB8/vBtOt48=; b=hALBQ3giWHBSi+BMBjEBuvt3oWUdCZjz7wdJhT7dgycpCR1NFJw0OsegownwY8SWpAn8 Xwbhxyx8Z6cIni/oCoTcAgLMvRreKTsKvDNeHoPee2eeW5tIi1cKwLnYkz9L9LEmL6Zsn8 bVjbuo7nkb+3SKlpM0UWDV2HAOyj3Ti8uMqj26e+vXLo9mLu1eymqN5+PCwaLCGvit2zYr 5p3zZC+ruEFENYhiU6CF9knoe2p5DpH5VbSD9+KNp6z5NSDxtcbk7EDJ+3PoP5h38aONQ+ Kx/y2Ixb1qW8CIAd91yPQXJvXxlbVAnmlbTJC6h07i5VM/Z7t6XdqahieQynHhdg== Received: by filterdrecv-d7bbbc8bf-nxr9l with SMTP id filterdrecv-d7bbbc8bf-nxr9l-1-64C3B732-F 2023-07-28 12:40:18.294961639 +0000 UTC m=+6786040.380695038 Received: from bionic.localdomain (unknown) by geopod-ismtpd-3 (SG) with ESMTP id Ce1ZcwZZQIGpzFQp9-WwwA Fri, 28 Jul 2023 12:40:18.006 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v4 3/5] usb: dwc3-generic: Relax unsupported dr_mode check Date: Fri, 28 Jul 2023 12:40:18 +0000 (UTC) Message-ID: <20230728124011.1747408-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230728124011.1747408-1-jonas@kwiboo.se> References: <20230728124011.1747408-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h=2F4frwVzxnNC6VnaS?= =?us-ascii?Q?Y7KLoDWjx9Ih4JRBnXQtPIN1ELR6+feJ1xWKl63?= =?us-ascii?Q?c3OaJbfBaNK3xpY5k5Or8L8WqACfdbRnK8S9tVN?= =?us-ascii?Q?kRX4jIVg5Vkw1z3GB8rSrEbZP0wNw8OgizOpxYg?= =?us-ascii?Q?Vg=2FVTrMVgftL0vQf6h2On4F2ZU+ldk2VAoSp=2FL?= To: Kever Yang , Simon Glass , Philipp Tomsich , Marek Vasut , Jean-Jacques Hiblot Cc: Akash Gajjar , Jagan Teki , FUKAUMI Naoki , Tianling Shen , u-boot@lists.denx.de, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean When dr_mode is peripheral or otg and U-Boot has not been built with DM_USB_GADGET support, booting such device may end up with: dwc3_glue_bind_common: subnode name: usb@fcc00000 Error binding driver 'dwc3-generic-wrapper': -6 Some drivers failed to bind initcall sequence 00000000effbca08 failed at call 0000000000a217c8 (err=-6) ### ERROR ### Please RESET the board ### Instead fail gracfully with ENODEV to allow board continue booting. dwc3_glue_bind_common: subnode name: usb@fcc00000 dwc3_glue_bind_common: unsupported dr_mode 3 Also use CONFIG_IS_ENABLED(USB_HOST) and change switch to if statements to improve readability of the code. Fixes: 446e3a205b87 ("dwc3-generic: Handle the PHYs, the clocks and the reset lines") Signed-off-by: Jonas Karlman --- v4: - Add fixes tag v3: - Update debug message to include dr_mode (Marek Vasut) v2: - Change to use CONFIG_IS_ENABLED for USB_HOST - Refactor switch to if statements (Marek Vasut) drivers/usb/dwc3/dwc3-generic.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 4d5d500aefab..2331ac453132 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -226,8 +226,7 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { }; #endif -#if defined(CONFIG_SPL_USB_HOST) || \ - !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_HOST) +#if CONFIG_IS_ENABLED(USB_HOST) static int dwc3_generic_host_probe(struct udevice *dev) { struct xhci_hcor *hcor; @@ -409,7 +408,7 @@ struct dwc3_glue_ops ti_ops = { static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node); - const char *driver = NULL; + const char *driver; enum usb_dr_mode dr_mode; struct udevice *dev; int ret; @@ -421,27 +420,17 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) if (!dr_mode) dr_mode = usb_get_dr_mode(node); - switch (dr_mode) { - case USB_DR_MODE_PERIPHERAL: - case USB_DR_MODE_OTG: -#if CONFIG_IS_ENABLED(DM_USB_GADGET) + if (CONFIG_IS_ENABLED(DM_USB_GADGET) && + (dr_mode == USB_DR_MODE_PERIPHERAL || dr_mode == USB_DR_MODE_OTG)) { debug("%s: dr_mode: OTG or Peripheral\n", __func__); driver = "dwc3-generic-peripheral"; -#endif - break; -#if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD) - case USB_DR_MODE_HOST: + } else if (CONFIG_IS_ENABLED(USB_HOST) && dr_mode == USB_DR_MODE_HOST) { debug("%s: dr_mode: HOST\n", __func__); driver = "dwc3-generic-host"; - break; -#endif - default: - debug("%s: unsupported dr_mode\n", __func__); + } else { + debug("%s: unsupported dr_mode %d\n", __func__, dr_mode); return -ENODEV; - }; - - if (!driver) - return -ENXIO; + } ret = device_bind_driver_to_node(parent, driver, name, node, &dev); -- 2.41.0