All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Kemnade <andreas@kemnade.info>
To: marex@denx.de, andreas@kemnade.info, u-boot@lists.denx.de,
	t-kristo@ti.com, kristo@kernel.org, tony@atomide.com
Subject: [PATCH 2/2] musb-new: omap2430: fix musb probing in gadget mode
Date: Sat, 26 Nov 2022 23:30:10 +0100	[thread overview]
Message-ID: <20221126223010.3319020-3-andreas@kemnade.info> (raw)
In-Reply-To: <20221126223010.3319020-1-andreas@kemnade.info>

Host mode structures were accessed but not initialized
and gadget dm did not compile at all.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/usb/musb-new/omap2430.c | 42 ++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index 7d15b94a6c..607592a1d0 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -46,6 +46,13 @@ static inline void omap2430_low_level_init(struct musb *musb)
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 }
 
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+{
+	struct musb_host_data *host = dev_get_priv(dev);
+
+	host->host->isr(0, host->host);
+	return 0;
+}
 
 static int omap2430_musb_init(struct musb *musb)
 {
@@ -214,37 +221,38 @@ static int omap2430_musb_of_to_plat(struct udevice *dev)
 
 static int omap2430_musb_probe(struct udevice *dev)
 {
-#ifdef CONFIG_USB_MUSB_HOST
 	struct musb_host_data *host = dev_get_priv(dev);
-#else
-	struct musb *musbp;
-#endif
+
 	struct omap2430_musb_plat *plat = dev_get_plat(dev);
-	struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
 	struct omap_musb_board_data *otg_board_data;
 	int ret = 0;
 	void *base = dev_read_addr_ptr(dev);
 
-	priv->desc_before_addr = true;
 
 	otg_board_data = &plat->otg_board_data;
 
-#ifdef CONFIG_USB_MUSB_HOST
+	if (IS_ENABLED(CONFIG_USB_MUSB_HOST)) {
+		struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
+
+		priv->desc_before_addr = true;
+		host->host = musb_init_controller(&plat->plat,
+						  (struct device *)otg_board_data,
+						  plat->base);
+		if (!host->host)
+			return -EIO;
+
+		return musb_lowlevel_init(host);
+	}
+
+	/* OTG still not supported, so forcing peripheral */
+	plat->plat.mode = MUSB_PERIPHERAL;
 	host->host = musb_init_controller(&plat->plat,
 					  (struct device *)otg_board_data,
 					  plat->base);
-	if (!host->host) {
+	if (!host->host)
 		return -EIO;
-	}
 
-	ret = musb_lowlevel_init(host);
-#else
-	musbp = musb_register(&plat->plat, (struct device *)otg_board_data,
-			      plat->base);
-	if (IS_ERR_OR_NULL(musbp))
-		return -EINVAL;
-#endif
-	return ret;
+	return usb_add_gadget_udc((struct device *)otg_board_data, &host->host->g);
 }
 
 static int omap2430_musb_remove(struct udevice *dev)
-- 
2.30.2


  parent reply	other threads:[~2022-11-27 13:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-26 22:30 [PATCH 0/2] musb-new: fix omap peripheral support Andreas Kemnade
2022-11-26 22:30 ` [PATCH 1/2] omap4: make musb probeable by simple bus Andreas Kemnade
2022-12-12 21:35   ` Tom Rini
2022-11-26 22:30 ` Andreas Kemnade [this message]
2022-11-26 22:50   ` [PATCH 2/2] musb-new: omap2430: fix musb probing in gadget mode Marek Vasut
2022-12-12 19:00   ` Tom Rini
2022-12-13  8:30     ` Andreas Kemnade
2022-12-13 20:32     ` Andreas Kemnade

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=20221126223010.3319020-3-andreas@kemnade.info \
    --to=andreas@kemnade.info \
    --cc=kristo@kernel.org \
    --cc=marex@denx.de \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.