From: Sam Edwards <cfsworks@gmail.com>
To: u-boot@lists.denx.de
Cc: Andre Przywara <andre.przywara@arm.com>,
Jagan Teki <jagan@amarulasolutions.com>,
Marek Vasut <marex@denx.de>,
Maksim Kiselev <bigunclemax@gmail.com>,
Sam Edwards <CFSworks@gmail.com>
Subject: [PATCH 3/3] usb: musb-new: sunxi: make compatible with UDC/DM gadget model
Date: Fri, 2 Jun 2023 15:49:58 -0600 [thread overview]
Message-ID: <20230602214958.167909-4-CFSworks@gmail.com> (raw)
In-Reply-To: <20230602214958.167909-1-CFSworks@gmail.com>
Since many sunxi boards do not implement a `board_usb_init`, it's
better if we just make the sunxi USB driver compatible with the
DM gadget model, as many other musb-new variants already are.
This change has been verified working on a T113s.
Signed-off-by: Sam Edwards <CFSworks@gmail.com>
---
drivers/usb/musb-new/sunxi.c | 60 +++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 65a528e229..ac6d1a41bb 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -432,6 +432,16 @@ static struct musb_hdrc_config musb_config_h3 = {
.ram_bits = SUNXI_MUSB_RAM_BITS,
};
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev) {
+ struct sunxi_glue *glue = dev_get_priv(dev);
+ struct musb_host_data *host = &glue->mdata;
+
+ 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);
@@ -440,10 +450,6 @@ static int musb_usb_probe(struct udevice *dev)
void *base = dev_read_addr_ptr(dev);
int ret;
-#ifdef CONFIG_USB_MUSB_HOST
- struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
-#endif
-
if (!base)
return -EINVAL;
@@ -474,25 +480,35 @@ static int musb_usb_probe(struct udevice *dev)
pdata.platform_ops = &sunxi_musb_ops;
pdata.config = glue->cfg->config;
-#ifdef CONFIG_USB_MUSB_HOST
- priv->desc_before_addr = true;
-
- pdata.mode = MUSB_HOST;
- host->host = musb_init_controller(&pdata, &glue->dev, base);
- if (!host->host)
- return -EIO;
-
- ret = musb_lowlevel_init(host);
- if (!ret)
- printf("Allwinner mUSB OTG (Host)\n");
-#else
- pdata.mode = MUSB_PERIPHERAL;
- host->host = musb_register(&pdata, &glue->dev, base);
- if (IS_ERR_OR_NULL(host->host))
- return -EIO;
+ if (IS_ENABLED(CONFIG_USB_MUSB_HOST)) {
+ struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
+ priv->desc_before_addr = true;
+
+ pdata.mode = MUSB_HOST;
+ host->host = musb_init_controller(&pdata, &glue->dev, base);
+ if (!host->host)
+ return -EIO;
+
+ ret = musb_lowlevel_init(host);
+ if (!ret)
+ printf("Allwinner mUSB OTG (Host)\n");
+ } else if (CONFIG_IS_ENABLED(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);
+ if (IS_ERR_OR_NULL(host->host))
+ return -EIO;
- printf("Allwinner mUSB OTG (Peripheral)\n");
-#endif
+ printf("Allwinner mUSB OTG (Peripheral)\n");
+ }
return ret;
}
--
2.39.2
next prev parent reply other threads:[~2023-06-02 21:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 21:49 [PATCH 0/3] Allwinner sunxi USB gadget improvements Sam Edwards
2023-06-02 21:49 ` [PATCH 1/3] usb: musb-new: sunxi: do not attempt to access NULL SRAMC Sam Edwards
2023-06-05 10:00 ` Marek Vasut
2023-06-05 11:04 ` Andre Przywara
2023-06-07 5:39 ` Sam Edwards
2023-06-07 10:45 ` Andre Przywara
2023-06-07 23:29 ` Sam Edwards
2023-06-02 21:49 ` [PATCH 2/3] usb: musb-new: sunxi: fix error check Sam Edwards
2023-06-05 10:01 ` Marek Vasut
2023-06-02 21:49 ` Sam Edwards [this message]
2023-06-05 10:02 ` [PATCH 3/3] usb: musb-new: sunxi: make compatible with UDC/DM gadget model Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230602214958.167909-4-CFSworks@gmail.com \
--to=cfsworks@gmail.com \
--cc=andre.przywara@arm.com \
--cc=bigunclemax@gmail.com \
--cc=jagan@amarulasolutions.com \
--cc=marex@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox