[PATCH 5/9] usb: dwc3: reset controller before using it
Sascha Hauer
s.hauer at pengutronix.de
Mon Oct 11 01:03:42 PDT 2021
Some dwc3 controllers have a reset assigned to them. Request it and
reset the device before using it.
Linux upstream driver uses an array of resets here, but in barebox we
currently do have this functionality, so for now use the first reset
only.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/usb/dwc3/core.c | 11 +++++++++++
drivers/usb/dwc3/core.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 04b700d12d..f618435cb6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -14,6 +14,7 @@
#include <dma.h>
#include <driver.h>
#include <init.h>
+#include <linux/reset.h>
#include "gadget.h"
#include "core.h"
@@ -1125,6 +1126,16 @@ static int dwc3_probe(struct device_d *dev)
if (ret)
return ret;
+ dwc->reset = reset_control_get(dev, NULL);
+ if (IS_ERR(dwc->reset)) {
+ dev_err(dev, "Failed to get reset control: %pe\n", dwc->reset);
+ return PTR_ERR(dwc->reset);
+ }
+
+ reset_control_assert(dwc->reset);
+ mdelay(1);
+ reset_control_deassert(dwc->reset);
+
dwc3_coresoft_reset(dwc);
dwc3_cache_hwparams(dwc);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index f2f7a311d1..94cc594920 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1003,6 +1003,8 @@ struct dwc3 {
struct clk_bulk_data *clks;
int num_clks;
+ struct reset_control *reset;
+
struct phy *usb2_generic_phy;
struct phy *usb3_generic_phy;
--
2.30.2
More information about the barebox
mailing list