Message ID | 20231231203930.1955090-1-aren@peacevolution.org |
---|---|
State | New |
Delegated to: | Andre Przywara |
Headers | show |
Series | usb: musb-new: sunxi: support usage with DM_USB_GADGET | expand |
On Sun, Dec 31, 2023 at 03:38:37PM -0500, Aren Moynihan wrote: > Add support for building the sunxi-musb driver with DM_USB_GADGET > including adding a separate IRQ handling function and registering the > driver with the musb system differently. Hi there, Were you aware of this similar patch? https://lore.kernel.org/u-boot/20230608195631.55364-1-CFSworks@gmail.com/ If not you might want to test it and compare it. John. > The implementation of usb_gadget_register_driver from > musb-new/musb_uboot.c only works when the gadget driver for the device > has already been probed and has called musb_register. On the pinephone > (using a allwinner a64 processor) this causes issues when trying to use > usb gadget mode (such as from the ums command) and CONFIG_USB_ETHER is > disabled. > > The implementation of usb_gadget_register_driver provided when > DM_USB_GADGET is enabled will probe the necessary drivers when it's > called. > > Without the patch, this is what the error condition looks like: > => ums 0 mmc 1 > UMS: LUN 0, dev mmc 1, hwpart 0, sector 0x0, count 0x3a3e000 > Controller uninitialized > g_dnl_register: failed!, error: -6 > g_dnl_register failed > > based on: > commit 2e4865bc6486 ("musb-new: omap2430: fix compiling in DM_USB_GADGET config") > > Signed-off-by: Aren Moynihan <aren@peacevolution.org>
On 12/31/23 9:38 PM, Aren Moynihan wrote: > Add support for building the sunxi-musb driver with DM_USB_GADGET > including adding a separate IRQ handling function and registering the > driver with the musb system differently. > > The implementation of usb_gadget_register_driver from > musb-new/musb_uboot.c only works when the gadget driver for the device > has already been probed and has called musb_register. On the pinephone > (using a allwinner a64 processor) this causes issues when trying to use > usb gadget mode (such as from the ums command) and CONFIG_USB_ETHER is > disabled. > > The implementation of usb_gadget_register_driver provided when > DM_USB_GADGET is enabled will probe the necessary drivers when it's > called. > > Without the patch, this is what the error condition looks like: > => ums 0 mmc 1 > UMS: LUN 0, dev mmc 1, hwpart 0, sector 0x0, count 0x3a3e000 > Controller uninitialized > g_dnl_register: failed!, error: -6 > g_dnl_register failed > > based on: > commit 2e4865bc6486 ("musb-new: omap2430: fix compiling in DM_USB_GADGET config") > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > --- > I don't fully understand what's going on here. Some gadget mode drivers, > such as usb ether (in usb_ether_init) will initialize the usb gadget > driver, but others (ums, fastboot) don't seem to do this, or don't do it > early enough, so they don't work. > > drivers/usb/musb-new/sunxi.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c > index 91f082fe05e..9b06f49ce47 100644 > --- a/drivers/usb/musb-new/sunxi.c > +++ b/drivers/usb/musb-new/sunxi.c > @@ -429,6 +429,17 @@ static struct musb_hdrc_config musb_config_h3 = { > .ram_bits = SUNXI_MUSB_RAM_BITS, > }; > > +#ifdef CONFIG_DM_USB_GADGET > +int dm_usb_gadget_handle_interrupts(struct udevice *dev) > +{ > + int n = 0; Is this used for anything? +CC Mattijs
On Thu, Apr 11, 2024 at 04:46:17PM +1000, John Watts wrote: > On Sun, Dec 31, 2023 at 03:38:37PM -0500, Aren Moynihan wrote: > > Add support for building the sunxi-musb driver with DM_USB_GADGET > > including adding a separate IRQ handling function and registering the > > driver with the musb system differently. > > Hi there, > > Were you aware of this similar patch? > > https://lore.kernel.org/u-boot/20230608195631.55364-1-CFSworks@gmail.com/ > > If not you might want to test it and compare it. > > John. I was not aware of that patch, it looks like it does the same thing as this one, but without some of the bugs. When comparing with it I realized that my dm_usb_gadget_handle_interrupts function is just plain wrong. I'll try to find time to test it soon. Thanks for the link - Aren > > The implementation of usb_gadget_register_driver from > > musb-new/musb_uboot.c only works when the gadget driver for the device > > has already been probed and has called musb_register. On the pinephone > > (using a allwinner a64 processor) this causes issues when trying to use > > usb gadget mode (such as from the ums command) and CONFIG_USB_ETHER is > > disabled. > > > > The implementation of usb_gadget_register_driver provided when > > DM_USB_GADGET is enabled will probe the necessary drivers when it's > > called. > > > > Without the patch, this is what the error condition looks like: > > => ums 0 mmc 1 > > UMS: LUN 0, dev mmc 1, hwpart 0, sector 0x0, count 0x3a3e000 > > Controller uninitialized > > g_dnl_register: failed!, error: -6 > > g_dnl_register failed > > > > based on: > > commit 2e4865bc6486 ("musb-new: omap2430: fix compiling in DM_USB_GADGET config") > > > > Signed-off-by: Aren Moynihan <aren@peacevolution.org>
Hi, On ven., avril 12, 2024 at 18:54, Aren <aren@peacevolution.org> wrote: > On Thu, Apr 11, 2024 at 04:46:17PM +1000, John Watts wrote: >> On Sun, Dec 31, 2023 at 03:38:37PM -0500, Aren Moynihan wrote: >> > Add support for building the sunxi-musb driver with DM_USB_GADGET >> > including adding a separate IRQ handling function and registering the >> > driver with the musb system differently. >> >> Hi there, >> >> Were you aware of this similar patch? >> >> https://lore.kernel.org/u-boot/20230608195631.55364-1-CFSworks@gmail.com/ >> >> If not you might want to test it and compare it. >> >> John. > > I was not aware of that patch, it looks like it does the same thing as > this one, but without some of the bugs. When comparing with it I > realized that my dm_usb_gadget_handle_interrupts function is just plain > wrong. > > I'll try to find time to test it soon. Please keep me in the loop for both progress on this one and on testing: https://lore.kernel.org/u-boot/20230608195631.55364-1-CFSworks@gmail.com/ > > Thanks for the link > - Aren > >> > The implementation of usb_gadget_register_driver from >> > musb-new/musb_uboot.c only works when the gadget driver for the device >> > has already been probed and has called musb_register. On the pinephone >> > (using a allwinner a64 processor) this causes issues when trying to use >> > usb gadget mode (such as from the ums command) and CONFIG_USB_ETHER is >> > disabled. >> > >> > The implementation of usb_gadget_register_driver provided when >> > DM_USB_GADGET is enabled will probe the necessary drivers when it's >> > called. >> > >> > Without the patch, this is what the error condition looks like: >> > => ums 0 mmc 1 >> > UMS: LUN 0, dev mmc 1, hwpart 0, sector 0x0, count 0x3a3e000 >> > Controller uninitialized >> > g_dnl_register: failed!, error: -6 >> > g_dnl_register failed >> > >> > based on: >> > commit 2e4865bc6486 ("musb-new: omap2430: fix compiling in DM_USB_GADGET config") >> > >> > Signed-off-by: Aren Moynihan <aren@peacevolution.org>
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 91f082fe05e..9b06f49ce47 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -429,6 +429,17 @@ static struct musb_hdrc_config musb_config_h3 = { .ram_bits = SUNXI_MUSB_RAM_BITS, }; +#ifdef CONFIG_DM_USB_GADGET +int dm_usb_gadget_handle_interrupts(struct udevice *dev) +{ + int n = 0; + struct musb_host_data *host = dev_get_priv(dev); + + host->host->isr(0, host->host); + return 0; +} +#endif + static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); @@ -482,6 +493,15 @@ static int musb_usb_probe(struct udevice *dev) ret = musb_lowlevel_init(host); if (!ret) printf("Allwinner mUSB OTG (Host)\n"); +#elifdef CONFIG_DM_USB_GADGET + pdata.mode = MUSB_PERIPHERAL; + host->host = musb_init_controller(&pdata, &glue->dev, base); + if (!host->host) + return -EIO; + + ret = usb_add_gadget_udc(&glue->dev, &host->host->g); + if (!ret) + printf("Allwinner mUSB OTG (Peripheral)\n"); #else pdata.mode = MUSB_PERIPHERAL; host->host = musb_register(&pdata, &glue->dev, base);
Add support for building the sunxi-musb driver with DM_USB_GADGET including adding a separate IRQ handling function and registering the driver with the musb system differently. The implementation of usb_gadget_register_driver from musb-new/musb_uboot.c only works when the gadget driver for the device has already been probed and has called musb_register. On the pinephone (using a allwinner a64 processor) this causes issues when trying to use usb gadget mode (such as from the ums command) and CONFIG_USB_ETHER is disabled. The implementation of usb_gadget_register_driver provided when DM_USB_GADGET is enabled will probe the necessary drivers when it's called. Without the patch, this is what the error condition looks like: => ums 0 mmc 1 UMS: LUN 0, dev mmc 1, hwpart 0, sector 0x0, count 0x3a3e000 Controller uninitialized g_dnl_register: failed!, error: -6 g_dnl_register failed based on: commit 2e4865bc6486 ("musb-new: omap2430: fix compiling in DM_USB_GADGET config") Signed-off-by: Aren Moynihan <aren@peacevolution.org> --- I don't fully understand what's going on here. Some gadget mode drivers, such as usb ether (in usb_ether_init) will initialize the usb gadget driver, but others (ums, fastboot) don't seem to do this, or don't do it early enough, so they don't work. drivers/usb/musb-new/sunxi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)