On 8/25/24 1:23 AM, Marek Vasut wrote:
On 8/23/24 11:22 AM, Zixun LI wrote:
On Fri, Aug 23, 2024 at 4:54 AM Marek Vasut <ma...@denx.de> wrote:

I think udc_bind_to_driver() should not call usb_gadget_connect() , that
connect should likely be called by at some later point.

Yes it's more logical, to keep it in disconnected state you prefer modify
controllers drivers init (I can do usba_udc and dwc2) or add a disconnect()
call ?

I think modify the init is the best option.

I also think
that drivers/usb/gadget/udc/udc-core.c might have to be extended to
provide some way to convert controller struct udevice to struct
usb_gadget , so when e.g. run_usb_dnl_gadget() calls
udc_device_get_by_index() and obtains struct udevice * , it can also get
matching struct usb_gadget * , and call the usb_gadget_connect().

What do you think ?

I think it's a good idea.

If there are multiple gadget controllers (very rare), since
usb_gadget_probe_driver() simply takes the first one from udc list,
is there a chance that the one to be started is different from the one
used by udc_device_get_by_index() ?

Yes, I think that chance exists.

I am looking at the usb_add_gadget_udc_release() and usb_gadget_probe_driver() and I am thinking, sigh, all that code is ready to be replaced by something cleaner which does not use this special struct usb_udc and udc_list, but instead only uses U-Boot DM udevices . But I am reluctant to ask you to do all that rework, because that is WAY out of scope of the problem you are trying to fix.

Maybe this could be a start (compile tested only):

https://source.denx.de/u-boot/custodians/u-boot-sh/-/commits/usb-udc-udevice

Reply via email to