Discussion:
[PATCH] USB: dwc2: add a call to device_reset_optional()
John Crispin
2014-10-10 17:26:41 UTC
Permalink
We need this for dwc2 to work on older ralink SoC like the rt3052.

Signed-off-by: John Crispin <blogic-***@public.gmane.org>
---
drivers/usb/dwc2/hcd.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..8b5f966 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -47,6 +47,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/usb.h>
+#include <linux/reset.h>

#include <linux/usb/hcd.h>
#include <linux/usb/ch11.h>
@@ -2764,6 +2765,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,

dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");

+ /* reset the device if a reset controller is present */
+ retval = device_reset_optional(hsotg->dev);
+ if (retval && retval != -ENOSYS)
+ return retval;
+
/* Detect config values from hardware */
retval = dwc2_get_hwparams(hsotg);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Paul Zimmerman
2014-10-14 19:54:53 UTC
Permalink
Sent: Friday, October 10, 2014 10:27 AM
We need this for dwc2 to work on older ralink SoC like the rt3052.
---
drivers/usb/dwc2/hcd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..8b5f966 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -47,6 +47,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/usb.h>
+#include <linux/reset.h>
#include <linux/usb/hcd.h>
#include <linux/usb/ch11.h>
@@ -2764,6 +2765,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
+ /* reset the device if a reset controller is present */
+ retval = device_reset_optional(hsotg->dev);
+ if (retval && retval != -ENOSYS)
+ return retval;
+
/* Detect config values from hardware */
retval = dwc2_get_hwparams(hsotg);
Hmm. Can you explain this a bit more? I'm not familiar with the reset
control API.

But I see that there is currently no user of device_reset_optional() in
the kernel. Looks like drivers typically call devm_reset_control_get()
in their probe functions, then save the returned pointer and call it
later to do the reset. I wonder why dwc2 would be the only driver not
to do it that way?
--
Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
John Crispin
2014-10-14 20:15:37 UTC
Permalink
Post by Paul Zimmerman
Sent: Friday, October 10, 2014 10:27 AM
We need this for dwc2 to work on older ralink SoC like the rt3052.
---
drivers/usb/dwc2/hcd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..8b5f966 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -47,6 +47,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/usb.h>
+#include <linux/reset.h>
#include <linux/usb/hcd.h>
#include <linux/usb/ch11.h>
@@ -2764,6 +2765,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
+ /* reset the device if a reset controller is present */
+ retval = device_reset_optional(hsotg->dev);
+ if (retval && retval != -ENOSYS)
+ return retval;
+
/* Detect config values from hardware */
retval = dwc2_get_hwparams(hsotg);
Hmm. Can you explain this a bit more? I'm not familiar with the reset
control API.
But I see that there is currently no user of device_reset_optional() in
the kernel. Looks like drivers typically call devm_reset_control_get()
in their probe functions, then save the returned pointer and call it
later to do the reset. I wonder why dwc2 would be the only driver not
to do it that way?
Hi,

we originally used device_reset(), when the reset api was new. this had
the problem that there was no stub in the headers for when the api was
not enabled.
when i rebased the patch last week, i simply checked the header file and
saw that there was a new stub and used it. hence the use of
device_reset_optional(). i will rework the patch and use
devm_reset_control_get instead.

John
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...