linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: dwc3: xilinx: Add gpio-reset support
@ 2022-05-04  7:53 Piyush Mehta
  2022-05-04  7:53 ` [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios Piyush Mehta
  2022-05-04  7:53 ` [PATCH 2/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta
  0 siblings, 2 replies; 4+ messages in thread
From: Piyush Mehta @ 2022-05-04  7:53 UTC (permalink / raw)
  To: gregkh, balbi, radheys, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, manish.narani
  Cc: linux-usb, devicetree, linux-arm-kernel, linux-kernel, git,
	sivadur, Piyush Mehta

These series of patches adds gpio-reset support in the dwc3-xilinx
glue driver.

The optional property added in dwc3-xilinx Linux binding document
and based on the 'reset-gpios' property dwc3-xilinx driver trigger
the GPIO ulpi-phy reset.

This reset is specific to the zynqMp.

Piyush Mehta (2):
  dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios
  usb: dwc3: xilinx: Add gpio-reset support

 Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml |  4 ++++
 drivers/usb/dwc3/dwc3-xilinx.c                         | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

-- 
2.7.4


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

* [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios
  2022-05-04  7:53 [PATCH 0/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta
@ 2022-05-04  7:53 ` Piyush Mehta
  2022-05-05  8:53   ` Krzysztof Kozlowski
  2022-05-04  7:53 ` [PATCH 2/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta
  1 sibling, 1 reply; 4+ messages in thread
From: Piyush Mehta @ 2022-05-04  7:53 UTC (permalink / raw)
  To: gregkh, balbi, radheys, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, manish.narani
  Cc: linux-usb, devicetree, linux-arm-kernel, linux-kernel, git,
	sivadur, Piyush Mehta

Added optional property support reset-gpios for the dwc3-Xilinx
glue driver.

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
---
 Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml b/Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml
index f77c16e..098b731 100644
--- a/Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml
+++ b/Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml
@@ -71,6 +71,10 @@ properties:
         - usb2-phy
         - usb3-phy
 
+  reset-gpios:
+    description: GPIO used for the reset ulpi-phy
+    maxItems: 1
+
 # Required child node:
 
 patternProperties:
-- 
2.7.4


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

* [PATCH 2/2] usb: dwc3: xilinx: Add gpio-reset support
  2022-05-04  7:53 [PATCH 0/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta
  2022-05-04  7:53 ` [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios Piyush Mehta
@ 2022-05-04  7:53 ` Piyush Mehta
  1 sibling, 0 replies; 4+ messages in thread
From: Piyush Mehta @ 2022-05-04  7:53 UTC (permalink / raw)
  To: gregkh, balbi, radheys, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, manish.narani
  Cc: linux-usb, devicetree, linux-arm-kernel, linux-kernel, git,
	sivadur, Piyush Mehta

This patch adds a USB GPIO based reset for dwc3-xilinx driver. The PHY
needs to be reset after the completion of phy initialization. As part
of the reset, check for gpio-reset binding before toggling the pin.
This feature is advantageous when the user toggle GPIO to trigger the
ULPI-PHY reset.

Delay of milliseconds is added in between low and high to meet the setup
and hold time requirement of the reset. The reset-gpio error handling is
added for error notification.

Some GPIO controllers must be accessed using message-based buses, like
I2C or SPI, to address this problem, updates GPIO access with sleep API.

This reset is specific to the zynqMp.

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
---
 drivers/usb/dwc3/dwc3-xilinx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index a6f3a9b..67b237c 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -13,6 +13,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/of_gpio.h>
 #include <linux/of_platform.h>
 #include <linux/pm_runtime.h>
 #include <linux/reset.h>
@@ -98,6 +99,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 {
 	struct device		*dev = priv_data->dev;
 	struct reset_control	*crst, *hibrst, *apbrst;
+	struct gpio_desc	*reset_gpio;
 	struct phy		*usb3_phy;
 	int			ret = 0;
 	u32			reg;
@@ -201,6 +203,21 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 	}
 
 skip_usb3_phy:
+	/* ulpi reset via gpio-modepin or gpio-framework driver */
+	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(reset_gpio)) {
+		return dev_err_probe(dev, PTR_ERR(reset_gpio),
+				     "Failed to request reset GPIO\n");
+	}
+
+	if (reset_gpio) {
+		/* Toggle ulpi to reset the phy. */
+		gpiod_set_value_cansleep(reset_gpio, 1);
+		usleep_range(5000, 10000);
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		usleep_range(5000, 10000);
+	}
+
 	/*
 	 * This routes the USB DMA traffic to go through FPD path instead
 	 * of reaching DDR directly. This traffic routing is needed to
-- 
2.7.4


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

* Re: [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios
  2022-05-04  7:53 ` [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios Piyush Mehta
@ 2022-05-05  8:53   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-05  8:53 UTC (permalink / raw)
  To: Piyush Mehta, gregkh, balbi, radheys, robh+dt,
	krzysztof.kozlowski+dt, michal.simek, manish.narani
  Cc: linux-usb, devicetree, linux-arm-kernel, linux-kernel, git, sivadur

On 04/05/2022 09:53, Piyush Mehta wrote:
> Added optional property support reset-gpios for the dwc3-Xilinx
> glue driver.
> 
> Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

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

end of thread, other threads:[~2022-05-05  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04  7:53 [PATCH 0/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta
2022-05-04  7:53 ` [PATCH 1/2] dt-bindings: usb: dwc3-xilinx: add optional property reset-gpios Piyush Mehta
2022-05-05  8:53   ` Krzysztof Kozlowski
2022-05-04  7:53 ` [PATCH 2/2] usb: dwc3: xilinx: Add gpio-reset support Piyush Mehta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).