Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: musb: musb_dsps: Wait for controller reset
@ 2026-10-14 17:47 Ettore Chimenti
  2026-10-14 17:59 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ettore Chimenti @ 2026-10-14 17:47 UTC (permalink / raw)
  To: Bin Liu, Greg Kroah-Hartman, Felipe Balbi, Ravi Babu,
	Ajay Kumar Gupta, andrew.goodbody, rouven.czerwinski
  Cc: linux-usb, linux-kernel, Ettore Chimenti

From: Andrew Goodbody <andrew.goodbody@linaro.org>

After soft resetting the USB controller wait for it to complete and then
set the mode of the controller. This ensures that the controller is in a
sane state. The timeout value used is just large as the board is likely
broken if it is ever reached so no need to optimise. It was tested with
a timeout of 500us which worked so gave it a 10x safety margin and used
5000us as the timeout value.

Fixes: 9ecb887522a0 ("usb: musb: Add support for ti81xx platform")
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
 drivers/usb/musb/musb_dsps.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index e3935f18dd56..d909c45c253d 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/irq.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
@@ -35,6 +36,7 @@
 #include "musb_core.h"
 
 static const struct of_device_id musb_dsps_of_match[];
+static int dsps_musb_set_mode(struct musb *musb, u8 mode);
 
 /*
  * DSPS musb wrapper register offset.
@@ -466,7 +468,13 @@ static int dsps_musb_init(struct musb *musb)
 	timer_setup(&musb->dev_timer, otg_timer, 0);
 
 	/* Reset the musb */
-	musb_writel(reg_base, wrp->control, (1 << wrp->reset));
+	musb_writel(reg_base, wrp->control, BIT(wrp->reset));
+	read_poll_timeout(musb_readl, val, !(val & BIT(wrp->reset)), 2, 5000,
+			  false, reg_base, wrp->control);
+	if (val & BIT(wrp->reset))
+		return -ENODEV;
+
+	dsps_musb_set_mode(musb, musb->port_mode);
 
 	musb->isr = dsps_interrupt;
 

---
base-commit: 0fcb05b72344f40806cbe810de8872f1698bf053
change-id: 20261014-patch-ektor5-dm8168-usb-d6ca2a5189f6

Best regards,
--  
Ettore Chimenti <ettore.chimenti@linaro.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-14 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 17:47 [PATCH] usb: musb: musb_dsps: Wait for controller reset Ettore Chimenti
2026-10-14 17:59 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox