Xilinx ZynqMP USB fixes
v8 cover Xilinx ZynqMP USB fixes
Some fixes related to the Xilinx ZynqMP DWC3 wrapper driver.
Changes since v7:
-Drop patches already merged. Add a patch to fix a bug found in one of those previous patches.
-Fixed error handling for reset GPIO
Changes since v6:
-skip USB core resets and register settings which are not necessary when USB3 PHY is not specified
-added patches to implement ULPI PHY reset in driver
Changes since v5:
-code formatting fixes, no functional change
Changes since v4:
-dropped DWC3 core patches as they are superseded by Sean Anderson's patchset "usb: dwc3: Calculate REFCLKPER et. al. from reference clock", ZynqMP-specific patches unchanged
Changes since v3:
-fixed DT schema dt-doc-validate error
Changes since v2:
-additional kerneldoc fixes
Changes since v1:
-added DT binding documentation for new attribute
-kerneldoc formatting and reworded comments
*** BLURB HERE ***
Robert Hancock (3):
usb: dwc3: xilinx: fix uninitialized return value
dt-bindings: usb: dwc3-xilinx: Added reset-gpios
usb: dwc3: xilinx: Add ULPI PHY reset handling
.../devicetree/bindings/usb/dwc3-xilinx.yaml | 4 ++++ drivers/usb/dwc3/dwc3-xilinx.c | 21 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
PATCH v8 1/3 usb: dwc3: xilinx: fix uninitialized return value
A previous patch to skip part of the initialization when a USB3 PHY was not present could result in the return value being uninitialized in that case, causing spurious probe failures. Initialize ret to 0 to avoid this.
--- drivers/usb/dwc3/dwc3-xilinx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-xilinx.c +1 -1
@@ -99,7 +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 phy *usb3_phy; -int ret; +int ret =0 ;u32 reg; usb3_phy =devm_phy_optional_get (dev,"usb3-phy" );
Signature · 1 line
2.31.1
PATCH v8 2/3 dt-bindings: usb: dwc3-xilinx: Added reset-gpios
In reply to Robert HancockUpdate DT binding to reflect new reset-gpios property.
--- Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml +4 -0
@@ -59,6 +59,10 @@ properties: - const: usb_hibrst - const: usb_apbrst + reset-gpios: + description: Optional GPIO connected to ULPI PHY reset line. + maxItems: 1 + phys: minItems: 1 maxItems: 2
Signature · 1 line
2.31.1
Rob Herring
maintainerRe: [PATCH v8 2/3] dt-bindings: usb: dwc3-xilinx: Added reset-gpios
Quoted 12 lines · Robert Hancock
Update DT binding to reflect new reset-gpios property.
Signed-off-by Robert Hancock <[email protected]>--- Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml +0
-0
Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml properties: · line 64
Quoted 6 lines
Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml +3
-0@@ -59,6 +59,10 @@ properties: - const: usb_hibrst - const: usb_apbrst + reset-gpios: + description: Optional GPIO connected to ULPI PHY reset line. + maxItems: 1
Reset for the PHY belongs in the PHY node.
Quoted 8 lines
Documentation/devicetree/bindings/usb/dwc3-xilinx.yaml +1
-0+ phys: minItems: 1 maxItems: 2Signature · 1 line
2.31.1
PATCH v8 3/3 usb: dwc3: xilinx: Add ULPI PHY reset handling
In reply to Robert HancockHook up an optional GPIO-based reset for the connected USB ULPI PHY device. This is typically already done by the first-stage boot loader, however it can be more robust to ensure this reset is done prior to loading the driver in Linux.
Based on a patch "usb: dwc3: xilinx: Add gpio-reset support" in the Xilinx kernel tree by Piyush Mehta <[email protected]>.
--- drivers/usb/dwc3/dwc3-xilinx.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/usb/dwc3/dwc3-xilinx.c +19 -0
@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/gpio/consumer.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/of_platform.h>
@@ -101,6 +102,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)struct phy *usb3_phy;int ret =0 ;u32 reg; +struct gpio_desc *reset_gpio; usb3_phy =devm_phy_optional_get (dev,"usb3-phy" );if (IS_ERR (usb3_phy)) {
@@ -110,6 +112,14 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) goto err; } + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +dev_err_probe (dev, ret, +"Failed to get reset gpio\n" ); + goto err; + } +/* * The following core resets are not required unless a USB3 PHY * is used, and the subsequent register settings are not required
@@ -201,6 +211,15 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) } skip_usb3_phy: +/* ulpi reset via gpio-modepin or gpio-framework driver */ +if (reset_gpio) { +/* Toggle ulpi to reset the phy. */ +gpiod_set_value (reset_gpio,0 ); +usleep_range (5000 ,10000 );/* delay */ +gpiod_set_value (reset_gpio,1 ); +usleep_range (5000 ,10000 );/* delay */ + } +/* * This routes the USB DMA traffic to go through FPD path instead * of reaching DDR directly. This traffic routing is needed to
Signature · 1 line
2.31.1
Re: [PATCH v8 3/3] usb: dwc3: xilinx: Add ULPI PHY reset handling
Hi Rob,
Quoted 55 lines · Robert Hancock
Hook up an optional GPIO-based reset for the connected USB ULPI PHY device. This is typically already done by the first-stage boot loader, however it can be more robust to ensure this reset is done prior to loading the driver in Linux.
Based on a patch "usb: dwc3: xilinx: Add gpio-reset support" in the Xilinx kernel tree by Piyush Mehta <[email protected]>.
Signed-off-by Robert Hancock <[email protected]>--- drivers/usb/dwc3/dwc3-xilinx.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/dwc3/dwc3-xilinx.c +12
-0@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/gpio/consumer.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/of_platform.h> @@ -101,6 +102,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)struct phy *usb3_phy;int ret =0 ;u32 reg; +struct gpio_desc *reset_gpio; usb3_phy =devm_phy_optional_get (dev,"usb3-phy" );if (IS_ERR (usb3_phy)) {@@ -110,6 +112,14 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) goto err; } + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +dev_err_probe (dev, ret, +"Failed to get reset gpio\n" ); + goto err; + } +/* * The following core resets are not required unless a USB3 PHY * is used, and the subsequent register settings are not required @@ -201,6 +211,15 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) } skip_usb3_phy: +/* ulpi reset via gpio-modepin or gpio-framework driver */ +if (reset_gpio) {
drivers/usb/dwc3/dwc3-xilinx.c static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) · line 225
Quoted 10 lines
drivers/usb/dwc3/dwc3-xilinx.c +7
-0+/* Toggle ulpi to reset the phy. */ +gpiod_set_value (reset_gpio,0 ); +usleep_range (5000 ,10000 );/* delay */ +gpiod_set_value (reset_gpio,1 ); +usleep_range (5000 ,10000 );/* delay */ + } +/* * This routes the USB DMA traffic to go through FPD path instead * of reaching DDR directly. This traffic routing is needed to
Do we need to have this in dwc3? Why not just use the usb-nop-xceiv driver (aka usb_phy_generic)?
--Sean
Re: [PATCH v8 3/3] usb: dwc3: xilinx: Add ULPI PHY reset handling
Quoted 67 lines · Sean Anderson
Hi Rob,
Quoted 64 lines · Robert Hancock
Hook up an optional GPIO-based reset for the connected USB ULPI PHY device. This is typically already done by the first-stage boot loader, however it can be more robust to ensure this reset is done prior to loading the driver in Linux.
Based on a patch "usb: dwc3: xilinx: Add gpio-reset support" in the Xilinx kernel tree by Piyush Mehta <[email protected]>.
Signed-off-by Robert Hancock <[email protected]>--- drivers/usb/dwc3/dwc3-xilinx.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/dwc3/dwc3- renamed from drivers/usb/dwc3/dwc3-xilinx.c +0
-0
xilinx.c
indexa6f3a9b38789..1ee6011ada44100644drivers/usb/dwc3/dwc3-xilinx.c +2
-0@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/gpio/consumer.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/of_platform.h> @@ -101,6 +102,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)struct phy *usb3_phy;int ret =0 ;u32 reg; +struct gpio_desc *reset_gpio; usb3_phy =devm_phy_optional_get (dev,"usb3-phy" );drivers/usb/dwc3/dwc3-xilinx.c +8
-0if (IS_ERR (usb3_phy)) {@@ -110,6 +112,14 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) goto err; } + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +dev_err_probe (dev, ret, +"Failed to get reset gpio\n" ); + goto err; + } +/* * The following core resets are not required unless a USB3 PHY drivers/usb/dwc3/dwc3-xilinx.c +8
-0* is used, and the subsequent register settings are not required @@ -201,6 +211,15 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) } skip_usb3_phy: +/* ulpi reset via gpio-modepin or gpio-framework driver */ +if (reset_gpio) { +/* Toggle ulpi to reset the phy. */ +gpiod_set_value (reset_gpio,0 ); +usleep_range (5000 ,10000 );/* delay */ +gpiod_set_value (reset_gpio,1 ); +usleep_range (5000 ,10000 );/* delay */ + }
Quoted 8 lines
Quoted 5 lines
drivers/usb/dwc3/dwc3-xilinx.c +1
-0+/* * This routes the USB DMA traffic to go through FPD path instead * of reaching DDR directly. This traffic routing is needed to
Do we need to have this in dwc3? Why not just use the usb-nop-xceiv driver (aka
usb_phy_generic)?
I hadn't noticed that option. Just tried it out and it seems like it does what's needed. So patches 2 and 3 can be dispensed with. Patch 1 is still needed however, I may resubmit that as a standalone patch..
Quoted 2 lines
--Sean
Signature · 3 lines
Robert Hancock Senior Hardware Designer, Calian Advanced Technologies www.calian.com
RE: [PATCH v8 3/3] usb: dwc3: xilinx: Add ULPI PHY reset handling
In reply to Robert HancockHello Robert,
Thanks for patch.
All the Xilinx USB resets are ACTIVE_LOW reset.
Regards,
Piyush Mehta
Quoted 45 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Thursday, January 27, 2022 5:10 AM
To: [email protected]
Cc: [email protected]; [email protected]; Michal Simek <[email protected]>; Manish Narani <[email protected]>; [email protected]; [email protected]; [email protected]; Piyush Mehta <[email protected]>; Robert Hancock <[email protected]>
Subject: [PATCH v8 3/3] usb: dwc3: xilinx: Add ULPI PHY reset handlingHook up an optional GPIO-based reset for the connected USB ULPI PHY device. This is typically already done by the first-stage boot loader, however it can be more robust to ensure this reset is done prior to loading the driver in Linux.
Based on a patch "usb: dwc3: xilinx: Add gpio-reset support" in the Xilinx kernel tree by Piyush Mehta <[email protected]>.
Signed-off-by Robert Hancock <[email protected]>--- drivers/usb/dwc3/dwc3-xilinx.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/dwc3/dwc3-xilinx.c +2
-0@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/gpio/consumer.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/of_platform.h> @@ -101,6 +102,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)struct phy *usb3_phy;int ret =0 ;u32 reg; +struct gpio_desc *reset_gpio; usb3_phy =devm_phy_optional_get (dev,"usb3-phy" );drivers/usb/dwc3/dwc3-xilinx.c +0
-0if (IS_ERR (usb3_phy)) {
drivers/usb/dwc3/dwc3-xilinx.c static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx · line 117
Quoted 6 lines
drivers/usb/dwc3/dwc3-xilinx.c +1
-0@@ -110,6 +112,14 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data) goto err; } + reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Note: Xilinx Support active low resets
Quoted 29 lines
drivers/usb/dwc3/dwc3-xilinx.c +7
-0+if (IS_ERR (reset_gpio)) { + ret =PTR_ERR (reset_gpio); +dev_err_probe (dev, ret, +"Failed to get reset gpio\n" ); + goto err; + } +/* drivers/usb/dwc3/dwc3-xilinx.c +0
-0* The following core resets are not required unless a USB3 PHY * is used, and the subsequent register settings are not required @@ - 201,6 +211,15 @@ static int
dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)drivers/usb/dwc3/dwc3-xilinx.c +9
-1} skip_usb3_phy: +/* ulpi reset via gpio-modepin or gpio-framework driver */ +if (reset_gpio) { +/* Toggle ulpi to reset the phy. */ +gpiod_set_value (reset_gpio,0 ); +usleep_range (5000 ,10000 );/* delay */ +gpiod_set_value (reset_gpio,1 ); +usleep_range (5000 ,10000 );/* delay */ + } +/* * This routes the USB DMA traffic to go through FPD path instead * of reaching DDR directly. This traffic routing is needed to -- 2.31.1