[PATCH v2] usb: musb: musb_dsps: Wait for controller reset
From: Ettore Chimenti
Date: Wed Oct 28 2026 - 09:32:15 EST
From: Andrew Goodbody <andrew.goodbody@xxxxxxxxxx>
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. If the reset times out let it cleanup on
error path exit to prevent leaks.
Fixes: 9ecb887522a0 ("usb: musb: Add support for ti81xx platform")
Signed-off-by: Andrew Goodbody <andrew.goodbody@xxxxxxxxxx>
Signed-off-by: Ettore Chimenti <ettore.chimenti@xxxxxxxxxx>
---
Changes in v2:
- Added cleanup on error path (Sashiko)
- Link to v1: https://patch.msgid.link/20261014-patch-ektor5-dm8168-usb-v1-1-9670414271d6@xxxxxxxxxx
To: Bin Liu <b-liu@xxxxxx>
To: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
To: Felipe Balbi <balbi@xxxxxx>
To: Ajay Kumar Gupta <ajay.gupta@xxxxxx>
To: Ravi Babu <ravibabu@xxxxxx>
Cc: linux-usb@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
drivers/usb/musb/musb_dsps.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index efd1f0dbb926..91958b7000d7 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,16 @@ 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)) {
+ phy_power_off(musb->phy);
+ phy_exit(musb->phy);
+ return -ENODEV;
+ }
+
+ dsps_musb_set_mode(musb, musb->port_mode);
musb->isr = dsps_interrupt;
---
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
change-id: 20261014-patch-ektor5-dm8168-usb-d6ca2a5189f6
Best regards,
--
Ettore Chimenti <ettore.chimenti@xxxxxxxxxx>