[PATCH v2] usb: dwc3: Add support to reset usb ULPI phy
Michal Simek
michal.simek at xilinx.com
Fri Mar 4 13:47:53 CET 2022
From: T Karthik Reddy <t.karthik.reddy at xilinx.com>
When usb PHY initialization is done, the PHY need to be reset.
Signed-off-by: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---
Changes in v2:
- Remove EBUSY checking which is not needed. Reported by Bin
drivers/usb/dwc3/Kconfig | 2 +-
drivers/usb/dwc3/dwc3-generic.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 62aa65bf0cd2..685bda3729e5 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -25,7 +25,7 @@ config USB_DWC3_OMAP
config USB_DWC3_GENERIC
bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)"
- depends on DM_USB && USB_DWC3 && MISC
+ depends on DM_USB && USB_DWC3 && MISC && DM_GPIO
help
Select this for Xilinx ZynqMP and similar Platforms.
This wrapper supports Host and Peripheral operation modes.
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index b1e019b5b91a..53355eb13a9c 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -25,6 +25,7 @@
#include <reset.h>
#include <clk.h>
#include <usb/xhci.h>
+#include <asm/gpio.h>
struct dwc3_glue_data {
struct clk_bulk clks;
@@ -42,6 +43,7 @@ struct dwc3_generic_priv {
void *base;
struct dwc3 dwc3;
struct phy_bulk phys;
+ struct gpio_desc ulpi_reset;
};
struct dwc3_generic_host_priv {
@@ -77,6 +79,26 @@ static int dwc3_generic_probe(struct udevice *dev,
if (rc && rc != -ENOTSUPP)
return rc;
+ if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) {
+ rc = gpio_request_by_name(dev->parent, "reset-gpios", 0,
+ &priv->ulpi_reset, GPIOD_ACTIVE_LOW);
+ if (rc)
+ return rc;
+
+ /* Toggle ulpi to reset the phy. */
+ rc = dm_gpio_set_value(&priv->ulpi_reset, 1);
+ if (rc)
+ return rc;
+
+ mdelay(5);
+
+ rc = dm_gpio_set_value(&priv->ulpi_reset, 0);
+ if (rc)
+ return rc;
+
+ mdelay(5);
+ }
+
if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3"))
reset_deassert_bulk(&glue->resets);
@@ -98,6 +120,12 @@ static int dwc3_generic_remove(struct udevice *dev,
{
struct dwc3 *dwc3 = &priv->dwc3;
+ if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) {
+ struct gpio_desc *ulpi_reset = &priv->ulpi_reset;
+
+ dm_gpio_free(ulpi_reset->dev, ulpi_reset);
+ }
+
dwc3_remove(dwc3);
dwc3_shutdown_phy(dev, &priv->phys);
unmap_physmem(dwc3->regs, MAP_NOCACHE);
--
2.35.1
More information about the U-Boot
mailing list