* [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET
@ 2023-12-31 20:38 Aren Moynihan
2024-04-11 6:46 ` John Watts
2024-04-12 13:06 ` Marek Vasut
0 siblings, 2 replies; 5+ messages in thread
From: Aren Moynihan @ 2023-12-31 20:38 UTC (permalink / raw)
To: u-boot
Cc: Sam Edwards, Samuel Holland, Jagan Teki, Andre Przywara,
Aren Moynihan, Marek Vasut
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;
+ 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);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET
2023-12-31 20:38 [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET Aren Moynihan
@ 2024-04-11 6:46 ` John Watts
2024-04-12 22:54 ` Aren
2024-04-12 13:06 ` Marek Vasut
1 sibling, 1 reply; 5+ messages in thread
From: John Watts @ 2024-04-11 6:46 UTC (permalink / raw)
To: Aren Moynihan
Cc: u-boot, Sam Edwards, Samuel Holland, Jagan Teki, Andre Przywara,
Marek Vasut
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>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET
2024-04-11 6:46 ` John Watts
@ 2024-04-12 22:54 ` Aren
2024-04-16 10:02 ` Mattijs Korpershoek
0 siblings, 1 reply; 5+ messages in thread
From: Aren @ 2024-04-12 22:54 UTC (permalink / raw)
To: John Watts
Cc: u-boot, Sam Edwards, Samuel Holland, Jagan Teki, Andre Przywara,
Marek Vasut
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>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET
2024-04-12 22:54 ` Aren
@ 2024-04-16 10:02 ` Mattijs Korpershoek
0 siblings, 0 replies; 5+ messages in thread
From: Mattijs Korpershoek @ 2024-04-16 10:02 UTC (permalink / raw)
To: Aren, John Watts
Cc: u-boot, Sam Edwards, Samuel Holland, Jagan Teki, Andre Przywara,
Marek Vasut
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET
2023-12-31 20:38 [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET Aren Moynihan
2024-04-11 6:46 ` John Watts
@ 2024-04-12 13:06 ` Marek Vasut
1 sibling, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2024-04-12 13:06 UTC (permalink / raw)
To: Aren Moynihan, u-boot, Mattijs Korpershoek
Cc: Sam Edwards, Samuel Holland, Jagan Teki, Andre Przywara
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-04-16 10:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-31 20:38 [PATCH] usb: musb-new: sunxi: support usage with DM_USB_GADGET Aren Moynihan
2024-04-11 6:46 ` John Watts
2024-04-12 22:54 ` Aren
2024-04-16 10:02 ` Mattijs Korpershoek
2024-04-12 13:06 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox