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 5492EEB64DA for ; Sun, 16 Jul 2023 07:53:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6595F86146; Sun, 16 Jul 2023 09:53:40 +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="DREOoazI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0901E857D5; Sun, 16 Jul 2023 09:53:39 +0200 (CEST) Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) (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 5CC2186146 for ; Sun, 16 Jul 2023 09:53:35 +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=mime-version:subject:references:from:in-reply-to:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=a5zR2ydn0QpMCCkp3Az+kfAfhY6ih45gU7ijckkpT5A=; b=DREOoazI2WQvA2VJBg5vx75Qr0kZwH+CMdisr+eIwFZVrQ6jGI5PXEmjBG887cRPJxF9 K+G49lrO5u2TCE+svn8g+wgEG0NrnVVsfOe1qxKEGNXl/T0PPj3yTgEl6oMM1psggsD0Tc NTW9OkX+9oUSro4/o56ouUpgvbA0dJtq+nsIbA4/8rcKhHVooSyVzHED9KZX4NIpVkKhm5 nBhK3YZhIqktAW+C6y+PxtuNhgzU2XNGlOrog6AJ8xUD9MHcTvV1Iil/w0pRa15uSpEqdE fLlpnUwvOkZ774arQpDZL8qR2RpiXiT2/uPd/JURaVX8Lf4/xmpZ+yqy3eha90DA== Received: by filterdrecv-66949dbc98-2h875 with SMTP id filterdrecv-66949dbc98-2h875-1-64B3A1FD-15 2023-07-16 07:53:33.869139873 +0000 UTC m=+5732034.792578933 Received: from [192.168.1.50] (unknown) by geopod-ismtpd-4 (SG) with ESMTP id JjYPWoFTSFOAnlN6Wh1cDw Sun, 16 Jul 2023 07:53:33.509 +0000 (UTC) Message-ID: Date: Sun, 16 Jul 2023 07:53:34 +0000 (UTC) MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 3/5] usb: dwc3-generic: Relax unsupported dr_mode check Content-Language: en-US References: <20230715231020.1694772-1-jonas@kwiboo.se> <20230715231020.1694772-4-jonas@kwiboo.se> <9e6bb1f1-7af1-cfe5-a433-087d4daac14e@denx.de> From: Jonas Karlman In-Reply-To: <9e6bb1f1-7af1-cfe5-a433-087d4daac14e@denx.de> X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h6YhiuJbA5ru=2FAf01?= =?us-ascii?Q?HfljfCbuAvUB=2FRVveRxtX8gpvoE6iJKXETCqaHz?= =?us-ascii?Q?LI24tDLrpLdA=2FynaJHQ0UhV4AfdDxh2etPOsBS0?= =?us-ascii?Q?y1xyX84OFrqCO3bJMt6vd53ycfMnNAzyAYT7Ij2?= =?us-ascii?Q?SCZoQ+FZc+jRgXBcAtSkqX=2FGrlkE8+zJldJOwK?= To: Marek Vasut , Kever Yang , Simon Glass , Philipp Tomsich Cc: Akash Gajjar , Jagan Teki , FUKAUMI Naoki , u-boot@lists.denx.de X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 On 2023-07-16 02:59, Marek Vasut wrote: > On 7/16/23 01:10, Jonas Karlman wrote: >> 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 >> >> Also use CONFIG_IS_ENABLED(USB_HOST) and change switch to if statements >> to improve readability of the code. >> >> Signed-off-by: Jonas Karlman >> --- >> v2: >> - Change to use CONFIG_IS_ENABLED for USB_HOST >> - Refactor switch to if statements (Marek Vasut) >> >> drivers/usb/dwc3/dwc3-generic.c | 25 +++++++------------------ >> 1 file changed, 7 insertions(+), 18 deletions(-) >> >> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c >> index 4d5d500aefab..6507219d6fc0 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: >> + } else { >> debug("%s: unsupported dr_mode\n", __func__); > > If you are already fixing this, please also print the actual dr_mode > that is unsupported, i.e. the aforementioned debug() output is useless > right now, just add dr_mode %s there. Sure, I can add a dr_mode %d to the debug message in a v3, dr_mode is enum not a string. Regards, Jonas