Re: [PATCH v2 2/2] usb: musb-new: sunxi: make compatible with UDC/DM gadget model

Andre Przywara
2024-07-14T22:25:21Z

On Sat, 29 Jun 2024 02:22:14 +1000
John Watts <contact@jookia.org> wrote:

Hi,

> On Fri, Jun 28, 2024 at 04:17:27PM +0100, Andre Przywara wrote:
> > > I do not know if this patch is still a
> > > necessity; though if John is nudging about it, it probably is.
> >
> > Yes apparently he needs it, though I am not entirely sure why.
> > USB gadget has worked for ages in sunxi, without DM_USB_GADGET support,
> > that's why I was a bit puzzled why this patch seems so important.
> >
> > And secondly I was put off by John's initial reply that it would trigger
> > many USB errors for him. He later rectified it, but I must have missed
> > that message.
>
> This patch is necessary for gadget to work on the T113 board I have.
> Without it I get this error during fastboot:
>
> Controller uninitialized
> g_dnl_register: failed!, error: -6

So I dug into this, and this is what I think is going on:

If you add "CONFIG_USB_MUSB_GADGET=y" to your *defconfig*, it should
work. If you just enable it via menuconfig or by editing .config, it
will not. Adding CONFIG_USB_ETHER to the mix should fix this.
This symbol is automatically selected in Kconfig when it sees
USB_MUSB_GADGET, but apparently only during a defconfig run, it's not
selected during the other methods. Not sure what causes this difference
in behaviour, but I have seen this in U-Boot before.

That being said: this is of course not a proper solution, the DM
support proposed in that patch is the right way to go, but it should
explain why it works for me, but not for you.

As for this patch: the problem is where the Ethernet gadget code
apparently grabs the UDC device, without actually using it already. This
prevents other gadgets like ums to be used, without unbinding the
Ethernet gadget with a non-obvious command first.
So I think we need a solution for this first, otherwise the user
experience would suffer.

Cheers,
Andre