All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] usb: dwc3: Add support to reset usb ULPI phy
@ 2022-07-08  9:21 Michal Simek
  2022-07-08 10:12 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2022-07-08  9:21 UTC (permalink / raw)
  To: u-boot, git, Marek Vasut
  Cc: T Karthik Reddy, Angus Ainslie, Jan Kiszka, Simon Glass

From: T Karthik Reddy <t.karthik.reddy@xilinx.com>

When usb PHY initialization is done, the PHY need to be reset.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---

Changes in v3:
- Fix compilation issues reported by CI and Marek
- Use CONFIG_IS_ENABLED(DM_GPIO) and remove Kconfig dependency

Changes in v2:
- Remove EBUSY checking which is not needed. Reported by Bin

The patch depends on
https://lore.kernel.org/all/152354d05f56c57a21a6306745051a0961ea3c66.1657271690.git.michal.simek@amd.com/

---
 drivers/usb/dwc3/dwc3-generic.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index c5310e465cbf..466b25a0c38e 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -26,6 +26,7 @@
 #include <reset.h>
 #include <clk.h>
 #include <usb/xhci.h>
+#include <asm/gpio.h>
 
 struct dwc3_glue_data {
 	struct clk_bulk		clks;
@@ -43,6 +44,7 @@ struct dwc3_generic_priv {
 	void *base;
 	struct dwc3 dwc3;
 	struct phy_bulk phys;
+	struct gpio_desc ulpi_reset;
 };
 
 struct dwc3_generic_host_priv {
@@ -78,6 +80,27 @@ static int dwc3_generic_probe(struct udevice *dev,
 	if (rc && rc != -ENOTSUPP)
 		return rc;
 
+	if (CONFIG_IS_ENABLED(DM_GPIO) &&
+	    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);
 
@@ -99,6 +122,13 @@ static int dwc3_generic_remove(struct udevice *dev,
 {
 	struct dwc3 *dwc3 = &priv->dwc3;
 
+	if (CONFIG_IS_ENABLED(DM_GPIO) &&
+	    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.36.1


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

* Re: [PATCH v3] usb: dwc3: Add support to reset usb ULPI phy
  2022-07-08  9:21 [PATCH v3] usb: dwc3: Add support to reset usb ULPI phy Michal Simek
@ 2022-07-08 10:12 ` Marek Vasut
  2022-07-08 10:20   ` Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2022-07-08 10:12 UTC (permalink / raw)
  To: Michal Simek, u-boot, git
  Cc: T Karthik Reddy, Angus Ainslie, Jan Kiszka, Simon Glass

On 7/8/22 11:21, Michal Simek wrote:
> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
> 
> When usb PHY initialization is done, the PHY need to be reset.

Michal, please verify this compiles in CI.

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

* Re: [PATCH v3] usb: dwc3: Add support to reset usb ULPI phy
  2022-07-08 10:12 ` Marek Vasut
@ 2022-07-08 10:20   ` Michal Simek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2022-07-08 10:20 UTC (permalink / raw)
  To: Marek Vasut, u-boot, git
  Cc: T Karthik Reddy, Angus Ainslie, Jan Kiszka, Simon Glass



On 7/8/22 12:12, Marek Vasut wrote:
> On 7/8/22 11:21, Michal Simek wrote:
>> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>
>> When usb PHY initialization is done, the PHY need to be reset.
> 
> Michal, please verify this compiles in CI.

I did it yesterday.
https://source.denx.de/u-boot/custodians/u-boot-microblaze/-/pipelines/12650

And my full queue is running just now.
https://source.denx.de/u-boot/custodians/u-boot-microblaze/-/pipelines/12652

M

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

end of thread, other threads:[~2022-07-08 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  9:21 [PATCH v3] usb: dwc3: Add support to reset usb ULPI phy Michal Simek
2022-07-08 10:12 ` Marek Vasut
2022-07-08 10:20   ` Michal Simek

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.