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 EC8FDD46C0F for ; Wed, 28 Jan 2026 22:51:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F4B783C2B; Wed, 28 Jan 2026 23:51:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine 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; secure) header.d=kwiboo.se header.i=@kwiboo.se header.b="GqPC3G0V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC28483C4B; Wed, 28 Jan 2026 23:51:10 +0100 (CET) Received: from smtp.forwardemail.net (smtp.forwardemail.net [121.127.44.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D537983BE1 for ; Wed, 28 Jan 2026 23:51:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=SRS0=20d3=AC=kwiboo.se=jonas@fe-bounces.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=Content-Transfer-Encoding: MIME-Version: Message-ID: Date: Subject: Cc: To: From; q=dns/txt; s=fe-e1b5cab7be; t=1769640666; bh=WRwoRaXLVZtXD+h/ipC8oT0DhFLfz0EOt61X0t8/W2Q=; b=GqPC3G0Vmh8D19jBk7U7h7TEo4+lGi+QLxujR1+virJ0pB8ou7iy4IZRwhxxrywEwwLnmRPhd 1MN79RbY1sJuvrSOXO5335zCjzccPQ9MLaAJE0vvSo+LBXBR9+3XQjTYpTtFxBZJ13v1BZeG6a3 szZuqkXqz0KMJD3UqyAnn85wsCEogtuUs2S/gVZ8Wm9GlMt3+jBQYDQ+br7VM4GV5p1oWh0VvgU PU0Yqw7N75MVPqBayzzTH4QFZPBRdRChyqHWAVUWrg94x2cVf+k0GEjq3Afm4tGlIVTngyuIl4C UPyeO9hFZiIsMi8WQzADWqIqDsgm30DHZ4Kw2TBCMf/g== X-Forward-Email-ID: 697a92d7c8e1d86c9dc2e1ae X-Forward-Email-Sender: rfc822; jonas@kwiboo.se, smtp.forwardemail.net, 121.127.44.73 X-Forward-Email-Version: 2.5.4 X-Forward-Email-Website: https://forwardemail.net X-Complaints-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Report-Abuse-To: abuse@forwardemail.net From: Jonas Karlman To: Marek Vasut , Lukasz Majewski , Mattijs Korpershoek , Tom Rini Cc: Jonas Karlman , u-boot@lists.denx.de Subject: [PATCH] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind() Date: Wed, 28 Jan 2026 22:50:55 +0000 Message-ID: <20260128225057.1699019-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Rockchip RK3288 and RK3506 contain two DWC2 USB controllers, typically one controller use dr_mode=otg and the other one use dr_mode=host. With USB_GADGET_DWC2_OTG, DM_USB_GADGET and USB_DWC2 enabled this result in the dwc2-udc-otg driver binding to both controllers, however only one will probe due to use of dr_mode=host on the other one. After the commit 6668b8e7cc68 ("dm: core: Support multiple drivers with same compatibles") it is possible to bind one controller to the dwc2-udc-otg driver and the other one to the dwc2_usb driver. Move the dr_mode check from of_to_plat() to bind() to allow dm core to bind the dwc2 host driver to dr_mode=host controllers. Before this: => dm tree ... usb_gadget 0 [ ] dwc2-udc-otg | |-- usb@ff740000 usb_gadget 1 [ ] dwc2-udc-otg | |-- usb@ff780000 => usb start starting USB... No USB controllers found After this: => dm tree ... usb_gadget 0 [ ] dwc2-udc-otg | |-- usb@ff740000 usb 0 [ ] dwc2_usb | |-- usb@ff780000 => usb start starting USB... USB DWC2 Bus usb@ff780000: 1 USB Device(s) found Signed-off-by: Jonas Karlman --- drivers/usb/gadget/dwc2_udc_otg.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 40393141ca95..d1d4fa7618b0 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -975,12 +975,6 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev) void (*set_params)(struct dwc2_plat_otg_data *data); int ret; - if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL && - usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) { - dev_dbg(dev, "Invalid mode\n"); - return -ENODEV; - } - plat->regs_otg = dev_read_addr(dev); plat->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0); @@ -1163,6 +1157,18 @@ static int dwc2_udc_otg_remove(struct udevice *dev) return dm_scan_fdt_dev(dev); } +static int dwc2_udc_otg_bind(struct udevice *dev) +{ + enum usb_dr_mode dr_mode = usb_get_dr_mode(dev_ofnode(dev)); + + if (dr_mode != USB_DR_MODE_PERIPHERAL && dr_mode != USB_DR_MODE_OTG) { + dev_dbg(dev, "Invalid mode\n"); + return -ENODEV; + } + + return 0; +} + static int dwc2_gadget_handle_interrupts(struct udevice *dev) { return dwc2_udc_handle_interrupt(); @@ -1186,6 +1192,7 @@ U_BOOT_DRIVER(dwc2_udc_otg) = { .of_match = dwc2_udc_otg_ids, .ops = &dwc2_gadget_ops, .of_to_plat = dwc2_udc_otg_of_to_plat, + .bind = dwc2_udc_otg_bind, .probe = dwc2_udc_otg_probe, .remove = dwc2_udc_otg_remove, .plat_auto = sizeof(struct dwc2_plat_otg_data), -- 2.52.0