U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Support MSM8916 USB PHY + UDC in qcom_defconfig
@ 2026-05-27  0:37 Sam Day
  2026-05-27  0:37 ` [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model Sam Day
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sam Day @ 2026-05-27  0:37 UTC (permalink / raw)
  To: Lukasz Majewski, Mattijs Korpershoek, Marek Vasut, Tom Rini,
	Neil Armstrong, Sumit Garg, Stephan Gerhold, Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

The MSM8916 SoC includes a ChipIdea UDC. The U-Boot driver for this UDC
is quite old, and did not support USB gadget driver model. As a result,
it could not be built alongside the DWC3 driver. This meant that
qcom_defconfig could not include support for USB on MSM8916.

This series adds support to build ChipIdea UDC with DM_USB_GADGET and
ensures that the newly introduced driver is registered from the MSM EHCI
glue driver.

The ChipIdea UDC driver continues to work without DM_USB_GADGET. I
tested these changes by building dragonboard410c_defconfig (which does
not enable DM_USB_GADGET), booting it, and then chain-booting (via
fastboot) another u-boot build built with qcom_defconfig. USB gadget
mode worked in both builds.

Signed-off-by: Sam Day <me@samcday.com>
---
Changes in v2 (thanks Stephan):
- Deduplicate CI UDC setup/teardown paths
- Formatting fix
- Regenerate qcom_defconfig with savedefconfig
- Link to v1: https://lore.kernel.org/r/20250412-msm8916-usb-v1-0-2925239caf4b@samcday.com

---
Sam Day (3):
      usb: udc: ci: support USB gadget driver model
      usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper
      qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC

 configs/qcom_defconfig      |   4 +-
 drivers/usb/gadget/Kconfig  |   1 -
 drivers/usb/gadget/ci_udc.c | 118 ++++++++++++++++++++++++++++++++++++--------
 drivers/usb/host/ehci-msm.c |   7 +++
 4 files changed, 107 insertions(+), 23 deletions(-)
---
base-commit: 987907ae4bcc5d6055bdf7d318a3edf53e14d5fa
change-id: 20250412-msm8916-usb-a1dc93c01bd5

Best regards,
-- 
Sam Day <me@samcday.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model
  2026-05-27  0:37 [PATCH v2 0/3] Support MSM8916 USB PHY + UDC in qcom_defconfig Sam Day
@ 2026-05-27  0:37 ` Sam Day
  2026-06-29 12:20   ` Mattijs Korpershoek
  2026-05-27  0:37 ` [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper Sam Day
  2026-05-27  0:38 ` [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC Sam Day
  2 siblings, 1 reply; 8+ messages in thread
From: Sam Day @ 2026-05-27  0:37 UTC (permalink / raw)
  To: Lukasz Majewski, Mattijs Korpershoek, Marek Vasut, Tom Rini,
	Neil Armstrong, Sumit Garg, Stephan Gerhold, Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

When CONFIG_DM_USB_GADGET is enabled, a UCLASS_USB_GADGET_GENERIC driver
will be defined that wraps the ChipIdea UDC operations. The
(dm_)?usb_gadget_.* symbols will no longer be defined (as these are now
handled by the UDC uclass).

If CONFIG_DM_USB_GADGET is not enabled, this driver behaves as it
previously did.

This new driver does not declare any compatibles of its own. It requires
a glue driver to bind it. The ehci_msm driver will be updated in the
following commit to do exactly that.

Signed-off-by: Sam Day <me@samcday.com>
---
 drivers/usb/gadget/Kconfig  |   1 -
 drivers/usb/gadget/ci_udc.c | 118 ++++++++++++++++++++++++++++++++++++--------
 2 files changed, 97 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 5390878254a..6ba558cc292 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -153,7 +153,6 @@ config USB_GADGET_OS_DESCRIPTORS
 
 config CI_UDC
 	bool "ChipIdea device controller"
-	depends on !DM_USB_GADGET
 	select USB_GADGET_DUALSPEED
 	help
 	  Say Y here to enable device controller functionality of the
diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index 4729570c525..42028e11d59 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -10,6 +10,7 @@
 #include <command.h>
 #include <config.h>
 #include <cpu_func.h>
+#include <dm.h>
 #include <net.h>
 #include <malloc.h>
 #include <wait_bit.h>
@@ -94,8 +95,17 @@ static struct usb_request *
 ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
 static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
 
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+static int ci_udc_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver);
+static int ci_udc_gadget_stop(struct usb_gadget *g);
+#endif
+
 static const struct usb_gadget_ops ci_udc_ops = {
 	.pullup = ci_pullup,
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+	.udc_start = ci_udc_gadget_start,
+	.udc_stop = ci_udc_gadget_stop,
+#endif
 };
 
 static const struct usb_ep_ops ci_ep_ops = {
@@ -978,7 +988,7 @@ void udc_irq(void)
 	}
 }
 
-int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+static int ci_udc_handle_interrupts(struct udevice *dev)
 {
 	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
 	u32 value;
@@ -1037,7 +1047,7 @@ static int ci_pullup(struct usb_gadget *gadget, int is_on)
 static int ci_udc_probe(void)
 {
 	struct ept_queue_head *head;
-	int i;
+	int i, ret;
 
 	const int num = 2 * NUM_ENDPOINTS;
 
@@ -1046,6 +1056,14 @@ static int ci_udc_probe(void)
 	const int eplist_raw_sz = num * sizeof(struct ept_queue_head);
 	const int eplist_sz = roundup(eplist_raw_sz, ARCH_DMA_MINALIGN);
 
+	if (IS_ENABLED(CONFIG_DM_USB))
+		ret = usb_setup_ehci_gadget(&controller.ctrl);
+	else
+		ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);
+
+	if (ret)
+		return ret;
+
 	/* The QH list must be aligned to 4096 bytes. */
 	controller.epts = memalign(eplist_align, eplist_sz);
 	if (!controller.epts)
@@ -1123,6 +1141,73 @@ static int ci_udc_probe(void)
 	return 0;
 }
 
+static void ci_udc_remove(void)
+{
+	if (IS_ENABLED(CONFIG_DM_USB)) {
+		usb_remove_ehci_gadget(&controller.ctrl);
+	} else {
+		usb_lowlevel_stop(0);
+		controller.ctrl = NULL;
+	}
+}
+
+static void ci_udc_stop(void)
+{
+	ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
+	free(controller.items_mem);
+	free(controller.epts);
+}
+
+static int ci_udc_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver)
+{
+	controller.driver = driver;
+	return 0;
+}
+
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+static int ci_udc_generic_probe(struct udevice *dev)
+{
+	int ret = ci_udc_probe();
+
+	if (ret)
+		return ret;
+
+	return usb_add_gadget_udc((struct device *)dev, &controller.gadget);
+}
+
+static int ci_udc_generic_remove(struct udevice *dev)
+{
+	usb_del_gadget_udc(&controller.gadget);
+
+	ci_udc_remove();
+
+	return 0;
+}
+
+static const struct usb_gadget_generic_ops ci_udc_generic_ops = {
+	.handle_interrupts	= ci_udc_handle_interrupts,
+};
+
+U_BOOT_DRIVER(ci_udc_generic) = {
+	.name = "ci-udc",
+	.id = UCLASS_USB_GADGET_GENERIC,
+	.ops = &ci_udc_generic_ops,
+	.probe = ci_udc_generic_probe,
+	.remove = ci_udc_generic_remove,
+};
+
+static int ci_udc_gadget_stop(struct usb_gadget *g)
+{
+	/* Avoid calling disconnect() twice; the UDC uclass already did it. */
+	controller.driver = NULL;
+	udc_disconnect();
+
+	ci_udc_stop();
+
+	return 0;
+}
+
+#else
 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 {
 	int ret;
@@ -1132,14 +1217,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 	if (!driver->bind || !driver->setup || !driver->disconnect)
 		return -EINVAL;
 
-#if CONFIG_IS_ENABLED(DM_USB)
-	ret = usb_setup_ehci_gadget(&controller.ctrl);
-#else
-	ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);
-#endif
-	if (ret)
-		return ret;
-
 	ret = ci_udc_probe();
 	if (ret) {
 		DBG("udc probe failed, returned %d\n", ret);
@@ -1151,7 +1228,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 		DBG("driver->bind() returned %d\n", ret);
 		return ret;
 	}
-	controller.driver = driver;
+
+	ci_udc_gadget_start(&controller.gadget, driver);
 
 	return 0;
 }
@@ -1163,20 +1241,18 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 	driver->unbind(&controller.gadget);
 	controller.driver = NULL;
 
-	ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
-	free(controller.items_mem);
-	free(controller.epts);
-
-#if CONFIG_IS_ENABLED(DM_USB)
-	usb_remove_ehci_gadget(&controller.ctrl);
-#else
-	usb_lowlevel_stop(0);
-	controller.ctrl = NULL;
-#endif
+	ci_udc_stop();
+	ci_udc_remove();
 
 	return 0;
 }
 
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+{
+	return ci_udc_handle_interrupts(dev);
+}
+#endif
+
 bool dfu_usb_get_reset(void)
 {
 	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;

-- 
2.54.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper
  2026-05-27  0:37 [PATCH v2 0/3] Support MSM8916 USB PHY + UDC in qcom_defconfig Sam Day
  2026-05-27  0:37 ` [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model Sam Day
@ 2026-05-27  0:37 ` Sam Day
  2026-06-29 12:33   ` Mattijs Korpershoek
  2026-05-27  0:38 ` [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC Sam Day
  2 siblings, 1 reply; 8+ messages in thread
From: Sam Day @ 2026-05-27  0:37 UTC (permalink / raw)
  To: Lukasz Majewski, Mattijs Korpershoek, Marek Vasut, Tom Rini,
	Neil Armstrong, Sumit Garg, Stephan Gerhold, Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

When CONFIG_DM_USB_GADGET is enabled, the CI UDC driver needs to be
explicitly bound. So we do this from the newly introduced glue driver.

Signed-off-by: Sam Day <me@samcday.com>
---
 drivers/usb/host/ehci-msm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index a58eff7cb9c..00719b7b575 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -161,6 +161,13 @@ static int qcom_ci_hdrc_bind(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	if (IS_ENABLED(CONFIG_DM_USB_GADGET) && IS_ENABLED(CONFIG_CI_UDC)) {
+		ret = device_bind_driver_to_node(dev, "ci-udc", "ci-udc",
+						 dev_ofnode(dev), NULL);
+		if (ret)
+			return ret;
+	}
+
 	if (!ofnode_valid(ulpi_node))
 		return 0;
 

-- 
2.54.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC
  2026-05-27  0:37 [PATCH v2 0/3] Support MSM8916 USB PHY + UDC in qcom_defconfig Sam Day
  2026-05-27  0:37 ` [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model Sam Day
  2026-05-27  0:37 ` [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper Sam Day
@ 2026-05-27  0:38 ` Sam Day
  2026-06-29 12:34   ` Mattijs Korpershoek
  2026-06-30  1:45   ` Balaji Selvanathan
  2 siblings, 2 replies; 8+ messages in thread
From: Sam Day @ 2026-05-27  0:38 UTC (permalink / raw)
  To: Lukasz Majewski, Mattijs Korpershoek, Marek Vasut, Tom Rini,
	Neil Armstrong, Sumit Garg, Stephan Gerhold, Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

Now that the ChipIdea UDC driver supports USB Gadget driver model, we
can enable it alongside the dwc3 generic driver.

Signed-off-by: Sam Day <me@samcday.com>
---
 configs/qcom_defconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig
index d0d54ec5a70..75e22f01f17 100644
--- a/configs/qcom_defconfig
+++ b/configs/qcom_defconfig
@@ -108,7 +108,6 @@ CONFIG_DWC_ETH_QOS_QCOM=y
 CONFIG_RGMII=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
-CONFIG_PHY=y
 CONFIG_PHY_QCOM_QMP_UFS=y
 CONFIG_PHY_QCOM_QUSB2=y
 CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=y
@@ -139,9 +138,12 @@ CONFIG_SYSRESET_QCOM_PSHOLD=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_MSM=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
+CONFIG_CI_UDC=y
 CONFIG_UFS=y
 CONFIG_UFS_QCOM=y
 CONFIG_VIDEO=y

-- 
2.54.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model
  2026-05-27  0:37 ` [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model Sam Day
@ 2026-06-29 12:20   ` Mattijs Korpershoek
  0 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2026-06-29 12:20 UTC (permalink / raw)
  To: Sam Day, Lukasz Majewski, Mattijs Korpershoek, Marek Vasut,
	Tom Rini, Neil Armstrong, Sumit Garg, Stephan Gerhold,
	Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

Hi Sam,

Thank you for the patch.
Sorry for the delays in the review for this one.

On Wed, May 27, 2026 at 00:37, Sam Day <me@samcday.com> wrote:

> When CONFIG_DM_USB_GADGET is enabled, a UCLASS_USB_GADGET_GENERIC driver
> will be defined that wraps the ChipIdea UDC operations. The
> (dm_)?usb_gadget_.* symbols will no longer be defined (as these are now
> handled by the UDC uclass).
>
> If CONFIG_DM_USB_GADGET is not enabled, this driver behaves as it
> previously did.
>
> This new driver does not declare any compatibles of its own. It requires
> a glue driver to bind it. The ehci_msm driver will be updated in the
> following commit to do exactly that.
>
> Signed-off-by: Sam Day <me@samcday.com>
> ---
>  drivers/usb/gadget/Kconfig  |   1 -
>  drivers/usb/gadget/ci_udc.c | 118 ++++++++++++++++++++++++++++++++++++--------
>  2 files changed, 97 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index 5390878254a..6ba558cc292 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -153,7 +153,6 @@ config USB_GADGET_OS_DESCRIPTORS
>  
>  config CI_UDC
>  	bool "ChipIdea device controller"
> -	depends on !DM_USB_GADGET
>  	select USB_GADGET_DUALSPEED
>  	help
>  	  Say Y here to enable device controller functionality of the
> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> index 4729570c525..42028e11d59 100644
> --- a/drivers/usb/gadget/ci_udc.c
> +++ b/drivers/usb/gadget/ci_udc.c
> @@ -10,6 +10,7 @@
>  #include <command.h>
>  #include <config.h>
>  #include <cpu_func.h>
> +#include <dm.h>
>  #include <net.h>
>  #include <malloc.h>
>  #include <wait_bit.h>
> @@ -94,8 +95,17 @@ static struct usb_request *
>  ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
>  static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
>  
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> +static int ci_udc_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver);
> +static int ci_udc_gadget_stop(struct usb_gadget *g);
> +#endif
> +
>  static const struct usb_gadget_ops ci_udc_ops = {
>  	.pullup = ci_pullup,
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> +	.udc_start = ci_udc_gadget_start,
> +	.udc_stop = ci_udc_gadget_stop,
> +#endif
>  };
>  
>  static const struct usb_ep_ops ci_ep_ops = {
> @@ -978,7 +988,7 @@ void udc_irq(void)
>  	}
>  }
>  
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +static int ci_udc_handle_interrupts(struct udevice *dev)
>  {
>  	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
>  	u32 value;
> @@ -1037,7 +1047,7 @@ static int ci_pullup(struct usb_gadget *gadget, int is_on)
>  static int ci_udc_probe(void)
>  {
>  	struct ept_queue_head *head;
> -	int i;
> +	int i, ret;
>  
>  	const int num = 2 * NUM_ENDPOINTS;
>  
> @@ -1046,6 +1056,14 @@ static int ci_udc_probe(void)
>  	const int eplist_raw_sz = num * sizeof(struct ept_queue_head);
>  	const int eplist_sz = roundup(eplist_raw_sz, ARCH_DMA_MINALIGN);
>  
> +	if (IS_ENABLED(CONFIG_DM_USB))
> +		ret = usb_setup_ehci_gadget(&controller.ctrl);
> +	else
> +		ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);
> +
> +	if (ret)
> +		return ret;
> +

What happens if later down in ci_udc_probe() we fail to finish the
function sucessfully?
For example, memalign(ILIST_ALIGN, ILIST_SZ) can return -ENOMEM.

Doesn't that leaves us with an usb that's halfway configured?
Shouldn't we add some error handling / do some cleanup in that case?

>  	/* The QH list must be aligned to 4096 bytes. */
>  	controller.epts = memalign(eplist_align, eplist_sz);
>  	if (!controller.epts)
> @@ -1123,6 +1141,73 @@ static int ci_udc_probe(void)
>  	return 0;
>  }
>  
> +static void ci_udc_remove(void)
> +{
> +	if (IS_ENABLED(CONFIG_DM_USB)) {
> +		usb_remove_ehci_gadget(&controller.ctrl);
> +	} else {
> +		usb_lowlevel_stop(0);
> +		controller.ctrl = NULL;
> +	}
> +}
> +
> +static void ci_udc_stop(void)
> +{
> +	ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
> +	free(controller.items_mem);
> +	free(controller.epts);

It feels a bit weird to free the endpoint request in stop().
Shouldn't we do this in the remove() function to match the
ci_ep_alloc_request() which is done in ci_udc_probe()?

> +}
> +
> +static int ci_udc_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver)
> +{
> +	controller.driver = driver;
> +	return 0;
> +}

Nitpick: could we please move this next to ci_udc_gadget_stop() ?
I know this would force you to write add controller.driver = driver in
usb_gadget_register_driver() but I don't this it's a problem given that
we do something similar in usb_gadget_unregister_driver().

> +
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> +static int ci_udc_generic_probe(struct udevice *dev)
> +{
> +	int ret = ci_udc_probe();
> +
> +	if (ret)
> +		return ret;
> +
> +	return usb_add_gadget_udc((struct device *)dev, &controller.gadget);
> +}
> +
> +static int ci_udc_generic_remove(struct udevice *dev)
> +{
> +	usb_del_gadget_udc(&controller.gadget);
> +
> +	ci_udc_remove();
> +
> +	return 0;
> +}
> +
> +static const struct usb_gadget_generic_ops ci_udc_generic_ops = {
> +	.handle_interrupts	= ci_udc_handle_interrupts,
> +};
> +
> +U_BOOT_DRIVER(ci_udc_generic) = {
> +	.name = "ci-udc",
> +	.id = UCLASS_USB_GADGET_GENERIC,
> +	.ops = &ci_udc_generic_ops,
> +	.probe = ci_udc_generic_probe,
> +	.remove = ci_udc_generic_remove,
> +};
> +
> +static int ci_udc_gadget_stop(struct usb_gadget *g)
> +{
> +	/* Avoid calling disconnect() twice; the UDC uclass already did it. */

There is no disconnect in udc-uclass.c? Did you mean "UDC core" here
instead of "UDC uclass" ?

> +	controller.driver = NULL;
> +	udc_disconnect();
> +
> +	ci_udc_stop();
> +
> +	return 0;
> +}
> +
> +#else
>  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  {
>  	int ret;
> @@ -1132,14 +1217,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  	if (!driver->bind || !driver->setup || !driver->disconnect)
>  		return -EINVAL;
>  
> -#if CONFIG_IS_ENABLED(DM_USB)
> -	ret = usb_setup_ehci_gadget(&controller.ctrl);
> -#else
> -	ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);
> -#endif
> -	if (ret)
> -		return ret;
> -
>  	ret = ci_udc_probe();
>  	if (ret) {
>  		DBG("udc probe failed, returned %d\n", ret);
> @@ -1151,7 +1228,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  		DBG("driver->bind() returned %d\n", ret);
>  		return ret;
>  	}
> -	controller.driver = driver;
> +
> +	ci_udc_gadget_start(&controller.gadget, driver);
>  
>  	return 0;
>  }
> @@ -1163,20 +1241,18 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
>  	driver->unbind(&controller.gadget);
>  	controller.driver = NULL;
>  
> -	ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
> -	free(controller.items_mem);
> -	free(controller.epts);
> -
> -#if CONFIG_IS_ENABLED(DM_USB)
> -	usb_remove_ehci_gadget(&controller.ctrl);
> -#else
> -	usb_lowlevel_stop(0);
> -	controller.ctrl = NULL;
> -#endif
> +	ci_udc_stop();
> +	ci_udc_remove();
>  
>  	return 0;
>  }
>  
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +{
> +	return ci_udc_handle_interrupts(dev);
> +}
> +#endif
> +
>  bool dfu_usb_get_reset(void)
>  {
>  	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
>
> -- 
> 2.54.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper
  2026-05-27  0:37 ` [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper Sam Day
@ 2026-06-29 12:33   ` Mattijs Korpershoek
  0 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2026-06-29 12:33 UTC (permalink / raw)
  To: Sam Day, Lukasz Majewski, Mattijs Korpershoek, Marek Vasut,
	Tom Rini, Neil Armstrong, Sumit Garg, Stephan Gerhold,
	Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

Hi Sam,

Thank you for the patch.

On Wed, May 27, 2026 at 00:37, Sam Day <me@samcday.com> wrote:

> When CONFIG_DM_USB_GADGET is enabled, the CI UDC driver needs to be
> explicitly bound. So we do this from the newly introduced glue driver.
>
> Signed-off-by: Sam Day <me@samcday.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC
  2026-05-27  0:38 ` [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC Sam Day
@ 2026-06-29 12:34   ` Mattijs Korpershoek
  2026-06-30  1:45   ` Balaji Selvanathan
  1 sibling, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2026-06-29 12:34 UTC (permalink / raw)
  To: Sam Day, Lukasz Majewski, Mattijs Korpershoek, Marek Vasut,
	Tom Rini, Neil Armstrong, Sumit Garg, Stephan Gerhold,
	Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Balaji Selvanathan, Petr Beneš,
	Heiko Schocher, Simon Glass, Aswin Murugan, Paul Sajna,
	Marek Vasut, Varadarajan Narayanan, Svyatoslav Ryhel,
	Ilias Apalodimas, Luca Weiss, Sam Day

Hi Sam,

Thank you for the patch.

On Wed, May 27, 2026 at 00:38, Sam Day <me@samcday.com> wrote:

> Now that the ChipIdea UDC driver supports USB Gadget driver model, we
> can enable it alongside the dwc3 generic driver.
>
> Signed-off-by: Sam Day <me@samcday.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC
  2026-05-27  0:38 ` [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC Sam Day
  2026-06-29 12:34   ` Mattijs Korpershoek
@ 2026-06-30  1:45   ` Balaji Selvanathan
  1 sibling, 0 replies; 8+ messages in thread
From: Balaji Selvanathan @ 2026-06-30  1:45 UTC (permalink / raw)
  To: Sam Day, Lukasz Majewski, Mattijs Korpershoek, Marek Vasut,
	Tom Rini, Neil Armstrong, Sumit Garg, Stephan Gerhold,
	Casey Connolly
  Cc: u-boot, u-boot-qcom, Quentin Schulz, Kever Yang, Peter Robinson,
	Jonas Karlman, George Chan, Petr Beneš, Heiko Schocher,
	Simon Glass, Aswin Murugan, Paul Sajna, Marek Vasut,
	Varadarajan Narayanan, Svyatoslav Ryhel, Ilias Apalodimas,
	Luca Weiss

Hi Sam,

Thanks for the patch.

On 5/27/2026 6:08 AM, Sam Day wrote:
> Now that the ChipIdea UDC driver supports USB Gadget driver model, we
> can enable it alongside the dwc3 generic driver.
>
> Signed-off-by: Sam Day <me@samcday.com>
> ---
>   configs/qcom_defconfig | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig
> index d0d54ec5a70..75e22f01f17 100644
> --- a/configs/qcom_defconfig
> +++ b/configs/qcom_defconfig
> @@ -108,7 +108,6 @@ CONFIG_DWC_ETH_QOS_QCOM=y
>   CONFIG_RGMII=y
>   CONFIG_PHY_MICREL=y
>   CONFIG_PHY_MICREL_KSZ90X1=y
> -CONFIG_PHY=y

Is this change related to the goal of this patch? Maybe we can have this 
as seperate patch?

Regards,

Balaji

>   CONFIG_PHY_QCOM_QMP_UFS=y
>   CONFIG_PHY_QCOM_QUSB2=y
>   CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=y
> @@ -139,9 +138,12 @@ CONFIG_SYSRESET_QCOM_PSHOLD=y
>   CONFIG_USB=y
>   CONFIG_USB_XHCI_HCD=y
>   CONFIG_USB_XHCI_DWC3=y
> +CONFIG_USB_EHCI_HCD=y
> +CONFIG_USB_EHCI_MSM=y
>   CONFIG_USB_DWC3=y
>   CONFIG_USB_DWC3_GENERIC=y
>   CONFIG_USB_GADGET=y
> +CONFIG_CI_UDC=y
>   CONFIG_UFS=y
>   CONFIG_UFS_QCOM=y
>   CONFIG_VIDEO=y
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-30  1:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27  0:37 [PATCH v2 0/3] Support MSM8916 USB PHY + UDC in qcom_defconfig Sam Day
2026-05-27  0:37 ` [PATCH v2 1/3] usb: udc: ci: support USB gadget driver model Sam Day
2026-06-29 12:20   ` Mattijs Korpershoek
2026-05-27  0:37 ` [PATCH v2 2/3] usb: host: ehci-msm: Register ChipIdea UDC from glue wrapper Sam Day
2026-06-29 12:33   ` Mattijs Korpershoek
2026-05-27  0:38 ` [PATCH v2 3/3] qcom_defconfig: Enable MSM8916 USB PHY + ChipIdea UDC Sam Day
2026-06-29 12:34   ` Mattijs Korpershoek
2026-06-30  1:45   ` Balaji Selvanathan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox