From: Stefan Eichenberger <eichest@gmail.com>
To: francesco.dolcini@toradex.com, trini@konsulko.com,
ilias.apalodimas@linaro.org, sbabic@nabladev.com,
festevam@gmail.com, uboot-imx@nxp.com,
marek.vasut+usb@mailbox.org, lukma@denx.de,
mkorpershoek@kernel.org, antoine.gouby@toradex.com,
alice.guo@nxp.com, stefan.eichenberger@toradex.com,
sjg@chromium.org, emanuele.ghidoli@toradex.com,
franz.schnyder@toradex.com, pbrobinson@gmail.com,
quentin.schulz@cherry.de, jbx6244@gmail.com, ye.li@nxp.com,
xu.yang_2@nxp.com, bmeng.cn@gmail.com, xypron.glpk@gmx.de,
hayashi.kunihiko@socionext.com, sean.anderson@linux.dev
Cc: u-boot@lists.u-boot-project.org
Subject: [PATCH v2 2/7] usb: ehci-mx6: bind the ChipIdea gadget driver
Date: Mon, 14 Sep 2026 09:42:44 +0200 [thread overview]
Message-ID: <20260914074314.12522-3-eichest@gmail.com> (raw)
In-Reply-To: <20260914074314.12522-1-eichest@gmail.com>
From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
ci_udc has no device tree match of its own, so bind it here for the
ports it can serve. This driver already owns the controller node.
A peripheral-only port is of no use as a host, so hand the node over
completely and decline to bind. An OTG port serves both roles, so bind
ci_udc in addition and stay bound. Neither device is probed at bind
time, so "usb start" probes this one and puts the controller into host
mode, while "ums" and "fastboot" probe the gadget one and put it into
device mode.
Boards that do not enable both CI_UDC and DM_USB_GADGET are unaffected.
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
drivers/usb/host/ehci-mx6.c | 38 +++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 25907f22612..8b997e88946 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -20,6 +20,8 @@
#include <asm/mach-imx/sys_proto.h>
#include <dm.h>
#include <asm/mach-types.h>
+#include <dm/device_compat.h>
+#include <dm/lists.h>
#include <power/regulator.h>
#include <linux/usb/otg.h>
#include <linux/usb/phy.h>
@@ -553,6 +555,41 @@ static int ehci_usb_phy_mode(struct udevice *dev)
return 0;
}
+static int ehci_usb_bind(struct udevice *dev)
+{
+ ofnode node = dev_ofnode(dev);
+ enum usb_dr_mode dr_mode;
+ int ret;
+
+ /*
+ * The ChipIdea gadget driver has no device tree match of its own: it
+ * shares this node, so this driver owns it and decides which roles
+ * are wanted here.
+ */
+ if (!IS_ENABLED(CONFIG_CI_UDC) || !CONFIG_IS_ENABLED(DM_USB_GADGET))
+ return 0;
+
+ dr_mode = usb_get_dr_mode(node);
+ if (dr_mode != USB_DR_MODE_PERIPHERAL && dr_mode != USB_DR_MODE_OTG)
+ return 0;
+
+ ret = device_bind_driver_to_node(dev->parent, "ci_udc",
+ ofnode_get_name(node), node, NULL);
+ if (ret) {
+ dev_err(dev, "failed to bind ChipIdea gadget: %d\n", ret);
+ return ret;
+ }
+
+ /*
+ * An OTG port serves both roles, so stay bound as well. Neither
+ * device is probed here: "usb start" probes this one and puts the
+ * controller into host mode, "ums" and "fastboot" probe the gadget
+ * one and put it into device mode. A peripheral-only port is of no
+ * use as a host, so hand the node over completely.
+ */
+ return dr_mode == USB_DR_MODE_OTG ? 0 : -ENODEV;
+}
+
static int ehci_usb_of_to_plat(struct udevice *dev)
{
struct usb_plat *plat = dev_get_plat(dev);
@@ -774,6 +811,7 @@ U_BOOT_DRIVER(usb_mx6) = {
.name = "ehci_mx6",
.id = UCLASS_USB,
.of_match = mx6_usb_ids,
+ .bind = ehci_usb_bind,
.of_to_plat = ehci_usb_of_to_plat,
.probe = ehci_usb_probe,
.remove = ehci_usb_remove,
--
2.55.0
next prev parent reply other threads:[~2026-09-14 14:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 7:42 [PATCH v2 0/7] usb: fix DWC3/gadget issues and enable USB on Toradex i.MX95 boards Stefan Eichenberger
2026-09-14 7:42 ` [PATCH v2 1/7] usb: ci_udc: add driver model support Stefan Eichenberger
2026-09-14 7:42 ` Stefan Eichenberger [this message]
2026-09-14 7:42 ` [PATCH v2 3/7] usb: dwc3-generic: fix ref clock lookup indexing wrong clk_bulk array Stefan Eichenberger
2026-09-14 19:26 ` Marek Vasut
2026-09-15 7:44 ` Stefan Eichenberger
2026-09-15 14:22 ` Marek Vasut
2026-09-14 7:42 ` [PATCH v2 4/7] usb: skip host-only devices when picking the ehci gadget controller Stefan Eichenberger
2026-09-14 19:31 ` Marek Vasut
2026-09-15 7:57 ` Stefan Eichenberger
2026-09-15 14:24 ` Marek Vasut
2026-09-16 12:47 ` Stefan Eichenberger
2026-09-16 14:29 ` Marek Vasut
2026-09-14 7:42 ` [PATCH v2 5/7] configs: verdin-imx95: enable CI_UDC usb gadget driver Stefan Eichenberger
2026-09-14 7:42 ` [PATCH v2 6/7] toradex: verdin-imx95: enable DWC3 USB controller support Stefan Eichenberger
2026-09-14 7:42 ` [PATCH v2 7/7] toradex: smarc-imx95: " Stefan Eichenberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914074314.12522-3-eichest@gmail.com \
--to=eichest@gmail.com \
--cc=alice.guo@nxp.com \
--cc=antoine.gouby@toradex.com \
--cc=bmeng.cn@gmail.com \
--cc=emanuele.ghidoli@toradex.com \
--cc=festevam@gmail.com \
--cc=francesco.dolcini@toradex.com \
--cc=franz.schnyder@toradex.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jbx6244@gmail.com \
--cc=lukma@denx.de \
--cc=marek.vasut+usb@mailbox.org \
--cc=mkorpershoek@kernel.org \
--cc=pbrobinson@gmail.com \
--cc=quentin.schulz@cherry.de \
--cc=sbabic@nabladev.com \
--cc=sean.anderson@linux.dev \
--cc=sjg@chromium.org \
--cc=stefan.eichenberger@toradex.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=uboot-imx@nxp.com \
--cc=xu.yang_2@nxp.com \
--cc=xypron.glpk@gmx.de \
--cc=ye.li@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox