Skip to contentSkip to conversation

Documentation: dt-bindings: dwc2: add the resets and reset-names property

PATCH In review [email protected] 4 participants 7 messages Apr 13, 2016 – Jun 3, 2016 4 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Documentation: dt-bindings: dwc2: add the resets and reset-names property

From: Dinh Nguyen <[email protected]>

Document the optional 'resets' and 'reset-names' property for the DWC2 usb core.

---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>

---
 Documentation/devicetree/bindings/usb/dwc2.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/dwc2.txt +3 -0
index 20a68bf..c9ccea6 100644
@@ -27,6 +27,9 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties
 - g-rx-fifo-size: size of rx fifo size in gadget mode.
 - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
 - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode.
+- resets: list of phandle and reset specifier pairs. The should be one entry for
+  softreset line of the USB IP.
+- reset-names: Should be "dwc2".
 
 Example:
 
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1460587442-21136-1-git-send-email-dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org

#2 lore raw

PATCH v3 2/2 usb: dwc2: Add reset control to dwc2

From: Dinh Nguyen <[email protected]>

Allow for platforms that have a reset controller driver in place to bring the USB IP out of reset.

---
v4: use dev_dbg() if not a -EPROBE_DEFER
v3: fix compile error
v2: move to lowlevel_hw_init()

---
 drivers/usb/dwc2/core.h     |  1 +
 drivers/usb/dwc2/platform.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/usb/dwc2/core.h +1 -0
index 3c58d63..f748132 100644
@@ -837,6 +837,7 @@ struct dwc2_hsotg {
 	void *priv;
 	int     irq;
 	struct clk *clk;
+	struct reset_control *reset;
 
 	unsigned int queuing_high_bandwidth:1;
 	unsigned int srp_success:1;
drivers/usb/dwc2/platform.c +15 -0
index 88629be..5e89af1 100644
@@ -45,6 +45,7 @@
 #include <linux/platform_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_data/s3c-hsotg.h>
+#include <linux/reset.h>
 
 #include <linux/usb/of.h>
 
@@ -337,6 +338,17 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
 	int i, ret;
 
+	hsotg->reset = devm_reset_control_get(hsotg->dev, "dwc2");
+	if (IS_ERR(hsotg->reset)) {
+		if (PTR_ERR(hsotg->reset) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		dev_dbg(hsotg->dev, "Could not get reset control.\n");
+		hsotg->reset = NULL;
+	}
+
+	if(hsotg->reset)
+		reset_control_deassert(hsotg->reset);
+
 	/* Set default UTMI width */
 	hsotg->phyif = GUSBCFG_PHYIF16;
 
@@ -434,6 +446,9 @@ static int dwc2_driver_remove(struct platform_device *dev)
 	if (hsotg->ll_hw_enabled)
 		dwc2_lowlevel_hw_disable(hsotg);
 
+	if (hsotg->reset)
+		reset_control_assert(hsotg->reset);
+
 	return 0;
 }
 
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1460587442-21136-2-git-send-email-dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org

#4 lore raw

Re: [PATCHv3 2/2] usb: dwc2: Add reset control to dwc2

Quoted 4 lines · On Thursday 14 April 2016, [email protected]…
drivers/usb/dwc2/platform.c +0 -0
@@ -337,6 +338,17 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
        int i, ret;
 

drivers/usb/dwc2/platform.c static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) · line 350

Quoted 10 lines
drivers/usb/dwc2/platform.c +10 -0
+       hsotg->reset = devm_reset_control_get(hsotg->dev, "dwc2");
+       if (IS_ERR(hsotg->reset)) {
+               if (PTR_ERR(hsotg->reset) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+               dev_dbg(hsotg->dev, "Could not get reset control.\n");
+               hsotg->reset = NULL;
+       }
+
+       if(hsotg->reset)
+               reset_control_deassert(hsotg->reset);

The error handling seems a bit odd here. If there is a failure to get the reset control and it's actually needed, I would argue the init function should not continue. Conversely, if there was no reset line specified in the device, why even print a message about it?

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCHv3 2/2] usb: dwc2: Add reset control to dwc2

Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Thursday 14 April 2016, [email protected]…
drivers/usb/dwc2/platform.c +0 -0
@@ -337,6 +338,17 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
        int i, ret;
 
Quoted 16 lines

drivers/usb/dwc2/platform.c static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) · line 350

Quoted 10 lines
drivers/usb/dwc2/platform.c +10 -0
+       hsotg->reset = devm_reset_control_get(hsotg->dev, "dwc2");
+       if (IS_ERR(hsotg->reset)) {
+               if (PTR_ERR(hsotg->reset) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+               dev_dbg(hsotg->dev, "Could not get reset control.\n");
+               hsotg->reset = NULL;
+       }
+
+       if(hsotg->reset)
+               reset_control_deassert(hsotg->reset);

The error handling seems a bit odd here. If there is a failure to get the reset control and it's actually needed, I would argue the init function should not continue. Conversely, if there was no reset line specified in the device, why even print a message about it?

Yes it's optional. I think this needs to be checked like the PHY's are checked in the same function. That is, by checking for specific error codes that indicate a reset control is not specified and continue only in that case. All other errors should be returned.

Dinh, care to make these changes?

As for the message, it's only purpose is to aid debugging.

John
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 570FE01C.3090109-HKixBCOQz3hWk0Htik3J/[email protected]

#8 lore raw

Re: [PATCHv3 2/2] usb: dwc2: Add reset control to dwc2

Quoted 23 lines · John Youn
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Thursday 14 April 2016, [email protected]…
drivers/usb/dwc2/platform.c +0 -0
@@ -337,6 +338,17 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
        int i, ret;
 
Quoted 16 lines

drivers/usb/dwc2/platform.c static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) · line 350

Quoted 10 lines
drivers/usb/dwc2/platform.c +10 -0
+       hsotg->reset = devm_reset_control_get(hsotg->dev, "dwc2");
+       if (IS_ERR(hsotg->reset)) {
+               if (PTR_ERR(hsotg->reset) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+               dev_dbg(hsotg->dev, "Could not get reset control.\n");
+               hsotg->reset = NULL;
+       }
+
+       if(hsotg->reset)
+               reset_control_deassert(hsotg->reset);

The error handling seems a bit odd here. If there is a failure to get the reset control and it's actually needed, I would argue the init function should not continue. Conversely, if there was no reset line specified in the device, why even print a message about it?

Quoted 6 lines

Yes it's optional. I think this needs to be checked like the PHY's are checked in the same function. That is, by checking for specific error codes that indicate a reset control is not specified and continue only in that case. All other errors should be returned.

Dinh, care to make these changes?

Sure, I can make the change.

Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#9 lore raw
In reply to a message not in the archive
Quoted 12 lines · On Wed, Apr 13, 2016 at 05:44:01PM -0500…

From: Dinh Nguyen <[email protected]>

Document the optional 'resets' and 'reset-names' property for the DWC2 usb core.

---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>

Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 3 +++
 1 file changed, 3 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Hi Rob,

Quoted 17 lines · Rob Herring
Quoted 12 lines · On Wed, Apr 13, 2016 at 05:44:01PM -0500…

From: Dinh Nguyen <[email protected]>

Document the optional 'resets' and 'reset-names' property for the DWC2 usb core.

---
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Kumar Gala <[email protected]>

Quoted 3 lines
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 3 +++
 1 file changed, 3 insertions(+)
Quoted 2 lines

Can you please apply this to your tree?

Thanks,
Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html