Skip to content

Commit ca05b38

Browse files
Piyush Mehtagregkh
authored andcommitted
usb: dwc3: xilinx: Add gpio-reset support
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1cda12b commit ca05b38

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/usb/dwc3/dwc3-xilinx.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/dma-mapping.h>
16+
#include <linux/of_gpio.h>
1617
#include <linux/of_platform.h>
1718
#include <linux/pm_runtime.h>
1819
#include <linux/reset.h>
@@ -98,6 +99,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
9899
{
99100
struct device *dev = priv_data->dev;
100101
struct reset_control *crst, *hibrst, *apbrst;
102+
struct gpio_desc *reset_gpio;
101103
struct phy *usb3_phy;
102104
int ret = 0;
103105
u32 reg;
@@ -201,6 +203,21 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
201203
}
202204

203205
skip_usb3_phy:
206+
/* ulpi reset via gpio-modepin or gpio-framework driver */
207+
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
208+
if (IS_ERR(reset_gpio)) {
209+
return dev_err_probe(dev, PTR_ERR(reset_gpio),
210+
"Failed to request reset GPIO\n");
211+
}
212+
213+
if (reset_gpio) {
214+
/* Toggle ulpi to reset the phy. */
215+
gpiod_set_value_cansleep(reset_gpio, 1);
216+
usleep_range(5000, 10000);
217+
gpiod_set_value_cansleep(reset_gpio, 0);
218+
usleep_range(5000, 10000);
219+
}
220+
204221
/*
205222
* This routes the USB DMA traffic to go through FPD path instead
206223
* of reaching DDR directly. This traffic routing is needed to

0 commit comments

Comments
 (0)