* [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind()
@ 2026-01-29 19:52 Jonas Karlman
2026-01-29 20:13 ` Mattijs Korpershoek
2026-01-30 8:02 ` Mattijs Korpershoek
0 siblings, 2 replies; 4+ messages in thread
From: Jonas Karlman @ 2026-01-29 19:52 UTC (permalink / raw)
To: Marek Vasut, Lukasz Majewski, Mattijs Korpershoek, Tom Rini
Cc: Jonas Karlman, u-boot
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:
dwc2-udc-otg usb@ff780000: Invalid dr_mode 1
=> 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 <jonas@kwiboo.se>
---
v2: Update dev_dbg message to include current dr_mode
---
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..e475b14b9ac3 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 dr_mode %d\n", dr_mode);
+ 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind()
2026-01-29 19:52 [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind() Jonas Karlman
@ 2026-01-29 20:13 ` Mattijs Korpershoek
2026-01-29 20:32 ` Marek Vasut
2026-01-30 8:02 ` Mattijs Korpershoek
1 sibling, 1 reply; 4+ messages in thread
From: Mattijs Korpershoek @ 2026-01-29 20:13 UTC (permalink / raw)
To: Jonas Karlman, Marek Vasut, Lukasz Majewski, Tom Rini
Cc: Jonas Karlman, u-boot
Hi Jonas,
Thank you for the patch.
On Thu, Jan 29, 2026 at 19:52, Jonas Karlman <jonas@kwiboo.se> wrote:
> 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:
>
> dwc2-udc-otg usb@ff780000: Invalid dr_mode 1
>
> => 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 <jonas@kwiboo.se>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Marek, can I pick this up since it's gadget or do you want to take it?
> ---
> v2: Update dev_dbg message to include current dr_mode
> ---
> drivers/usb/gadget/dwc2_udc_otg.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind()
2026-01-29 20:13 ` Mattijs Korpershoek
@ 2026-01-29 20:32 ` Marek Vasut
0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2026-01-29 20:32 UTC (permalink / raw)
To: Mattijs Korpershoek, Jonas Karlman, Tom Rini; +Cc: u-boot
On 1/29/26 9:13 PM, Mattijs Korpershoek wrote:
> Hi Jonas,
>
> Thank you for the patch.
>
> On Thu, Jan 29, 2026 at 19:52, Jonas Karlman <jonas@kwiboo.se> wrote:
>
>> 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:
>>
>> dwc2-udc-otg usb@ff780000: Invalid dr_mode 1
>>
>> => 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 <jonas@kwiboo.se>
>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
>
> Marek, can I pick this up since it's gadget or do you want to take it?
Sure, go for it
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
Thanks !
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind()
2026-01-29 19:52 [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind() Jonas Karlman
2026-01-29 20:13 ` Mattijs Korpershoek
@ 2026-01-30 8:02 ` Mattijs Korpershoek
1 sibling, 0 replies; 4+ messages in thread
From: Mattijs Korpershoek @ 2026-01-30 8:02 UTC (permalink / raw)
To: Marek Vasut, Lukasz Majewski, Tom Rini, Jonas Karlman; +Cc: u-boot
Hi,
On Thu, 29 Jan 2026 19:52:05 +0000, Jonas Karlman wrote:
> 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.
>
> [...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/1] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind()
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/e69841fa71d67c560d767b786f956bb6f2873130
--
Mattijs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-30 8:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 19:52 [PATCH v2] usb: gadget: dwc2: Move dr_mode check from of_to_plat() to bind() Jonas Karlman
2026-01-29 20:13 ` Mattijs Korpershoek
2026-01-29 20:32 ` Marek Vasut
2026-01-30 8:02 ` Mattijs Korpershoek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.