John Crispin
2014-10-16 20:34:10 UTC
We need this for dwc2 to work on older ralink SoC like the rt3052. Without, we
see the following when loading the driver:
[ 0.760000] dwc2 101c0000.usb: Bad value for GSNPSID: 0x00000000
Signed-off-by: John Crispin <blogic-***@public.gmane.org>
---
Changes since V1
* move the OF lookup call into the platform code
* add code to the cleanup path that puts the core back into reset
drivers/usb/dwc2/core.h | 3 +++
drivers/usb/dwc2/hcd.c | 11 +++++++++++
drivers/usb/dwc2/platform.c | 5 +++++
3 files changed, 19 insertions(+)
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..8dfd16a 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -42,6 +42,7 @@
#include <linux/usb/gadget.h>
#include <linux/usb/otg.h>
#include <linux/usb/phy.h>
+#include <linux/reset.h>
#include "hw.h"
#ifdef DWC2_LOG_WRITES
@@ -596,6 +597,8 @@ struct dwc2_hsotg {
unsigned int queuing_high_bandwidth:1;
unsigned int srp_success:1;
+ struct reset_control *reset_control;
+
struct workqueue_struct *wq_otg;
struct work_struct wf_otg;
struct timer_list wkp_timer;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..ff2ca4b 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2764,6 +2764,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
+ /* bring the device out of reset */
+ if (hsotg->reset_control) {
+ int retval = reset_control_deassert(hsotg->reset_control);
+
+ if (retval)
+ return retval;
+ }
+
/* Detect config values from hardware */
retval = dwc2_get_hwparams(hsotg);
@@ -2973,6 +2981,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
dwc2_hcd_release(hsotg);
usb_put_hcd(hcd);
+ if (hsotg->reset_control)
+ reset_control_assert(hsotg->reset_control);
+
#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
kfree(hsotg->last_frame_num_array);
kfree(hsotg->frame_num_array);
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index a10e7a3..6d74583 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -120,6 +120,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
const struct dwc2_core_params *params;
struct dwc2_core_params defparams;
struct dwc2_hsotg *hsotg;
+ struct reset_control *reset_control;
struct resource *res;
int retval;
int irq;
@@ -171,6 +172,10 @@ static int dwc2_driver_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)res->start, hsotg->regs);
+ reset_control = devm_reset_control_get(&dev->dev, NULL);
+ if (!IS_ERR(reset_control))
+ hsotg->reset_control = reset_control;
+
retval = dwc2_hcd_init(hsotg, irq, params);
if (retval)
return retval;
see the following when loading the driver:
[ 0.760000] dwc2 101c0000.usb: Bad value for GSNPSID: 0x00000000
Signed-off-by: John Crispin <blogic-***@public.gmane.org>
---
Changes since V1
* move the OF lookup call into the platform code
* add code to the cleanup path that puts the core back into reset
drivers/usb/dwc2/core.h | 3 +++
drivers/usb/dwc2/hcd.c | 11 +++++++++++
drivers/usb/dwc2/platform.c | 5 +++++
3 files changed, 19 insertions(+)
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..8dfd16a 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -42,6 +42,7 @@
#include <linux/usb/gadget.h>
#include <linux/usb/otg.h>
#include <linux/usb/phy.h>
+#include <linux/reset.h>
#include "hw.h"
#ifdef DWC2_LOG_WRITES
@@ -596,6 +597,8 @@ struct dwc2_hsotg {
unsigned int queuing_high_bandwidth:1;
unsigned int srp_success:1;
+ struct reset_control *reset_control;
+
struct workqueue_struct *wq_otg;
struct work_struct wf_otg;
struct timer_list wkp_timer;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..ff2ca4b 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2764,6 +2764,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
+ /* bring the device out of reset */
+ if (hsotg->reset_control) {
+ int retval = reset_control_deassert(hsotg->reset_control);
+
+ if (retval)
+ return retval;
+ }
+
/* Detect config values from hardware */
retval = dwc2_get_hwparams(hsotg);
@@ -2973,6 +2981,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
dwc2_hcd_release(hsotg);
usb_put_hcd(hcd);
+ if (hsotg->reset_control)
+ reset_control_assert(hsotg->reset_control);
+
#ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
kfree(hsotg->last_frame_num_array);
kfree(hsotg->frame_num_array);
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index a10e7a3..6d74583 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -120,6 +120,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
const struct dwc2_core_params *params;
struct dwc2_core_params defparams;
struct dwc2_hsotg *hsotg;
+ struct reset_control *reset_control;
struct resource *res;
int retval;
int irq;
@@ -171,6 +172,10 @@ static int dwc2_driver_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)res->start, hsotg->regs);
+ reset_control = devm_reset_control_get(&dev->dev, NULL);
+ if (!IS_ERR(reset_control))
+ hsotg->reset_control = reset_control;
+
retval = dwc2_hcd_init(hsotg, irq, params);
if (retval)
return retval;
--
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
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