All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
@ 2015-08-18  9:40 Yunzhi Li
  2015-08-18 23:03 ` Doug Anderson
  2015-08-19  0:19 ` John Youn
  0 siblings, 2 replies; 7+ messages in thread
From: Yunzhi Li @ 2015-08-18  9:40 UTC (permalink / raw)
  To: jwerner, dianders
  Cc: huangtao, cf, hl, Yunzhi Li, John Youn, Greg Kroah-Hartman,
	linux-usb, linux-kernel

We initiate dwc2 usb controller in BIOS, dwc2_core_reset() should
be called before dwc2_get_hwparams() to reset core registers to
default value. Without this the FIFO setting might be incorrect
because calculating FIFO size need power-on value of
GRXFSIZ/GNPTXFSIZ/HPTXFSIZ registers.

This patch could avoid warnning massage like in rk3288 platform:
[    2.074764] dwc2 ff580000.usb: 256 invalid for
host_perio_tx_fifo_size. Check HW configuration.

Signed-off-by: Yunzhi Li <lyz@rock-chips.com>

---

 drivers/usb/dwc2/core.c     | 2 +-
 drivers/usb/dwc2/core.h     | 1 +
 drivers/usb/dwc2/platform.c | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index c3cc1a7..86d1d65 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -474,7 +474,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg)
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
-static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
+int dwc2_core_reset(struct dwc2_hsotg *hsotg)
 {
 	u32 greset;
 	int count = 0;
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 0ed87620..5d95aec 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -846,6 +846,7 @@ enum dwc2_halt_status {
  * The following functions support initialization of the core driver component
  * and the DWC_otg controller
  */
+extern int dwc2_core_reset(struct dwc2_hsotg *hsotg);
 extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
 extern int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg);
 extern int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore);
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 9093530..8d3be4a 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -243,6 +243,12 @@ static int dwc2_driver_probe(struct platform_device *dev)
 	spin_lock_init(&hsotg->lock);
 	mutex_init(&hsotg->init_mutex);
 
+	/*
+	 * Reset before dwc2_get_hwparams() then it could get power-on real
+	 * reset value form registers.
+	 */
+	dwc2_core_reset(hsotg);
+
 	/* Detect config values from hardware */
 	retval = dwc2_get_hwparams(hsotg);
 	if (retval)
-- 
2.0.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-08-18  9:40 [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams() Yunzhi Li
@ 2015-08-18 23:03 ` Doug Anderson
  2015-08-19  0:19 ` John Youn
  1 sibling, 0 replies; 7+ messages in thread
From: Doug Anderson @ 2015-08-18 23:03 UTC (permalink / raw)
  To: Yunzhi Li
  Cc: Julius Werner, Tao Huang, Eddie Cai, Lin Huang, John Youn,
	Greg Kroah-Hartman, linux-usb, linux-kernel

lyz,

On Tue, Aug 18, 2015 at 2:40 AM, Yunzhi Li <lyz@rock-chips.com> wrote:
> We initiate dwc2 usb controller in BIOS, dwc2_core_reset() should
> be called before dwc2_get_hwparams() to reset core registers to
> default value. Without this the FIFO setting might be incorrect
> because calculating FIFO size need power-on value of
> GRXFSIZ/GNPTXFSIZ/HPTXFSIZ registers.
>
> This patch could avoid warnning massage like in rk3288 platform:
> [    2.074764] dwc2 ff580000.usb: 256 invalid for
> host_perio_tx_fifo_size. Check HW configuration.
>
> Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
>
> ---
>
>  drivers/usb/dwc2/core.c     | 2 +-
>  drivers/usb/dwc2/core.h     | 1 +
>  drivers/usb/dwc2/platform.c | 6 ++++++
>  3 files changed, 8 insertions(+), 1 deletion(-)

This seems reasonable to me.

Reviewed-by: Douglas Anderson <dianders@chromium.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-08-18  9:40 [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams() Yunzhi Li
  2015-08-18 23:03 ` Doug Anderson
@ 2015-08-19  0:19 ` John Youn
  2015-10-01 20:50   ` Doug Anderson
  1 sibling, 1 reply; 7+ messages in thread
From: John Youn @ 2015-08-19  0:19 UTC (permalink / raw)
  To: Yunzhi Li, jwerner, dianders
  Cc: huangtao, cf, hl, John Youn, Greg Kroah-Hartman, linux-usb, linux-kernel

On 8/18/2015 2:41 AM, Yunzhi Li wrote:
> We initiate dwc2 usb controller in BIOS, dwc2_core_reset() should
> be called before dwc2_get_hwparams() to reset core registers to
> default value. Without this the FIFO setting might be incorrect
> because calculating FIFO size need power-on value of
> GRXFSIZ/GNPTXFSIZ/HPTXFSIZ registers.
> 
> This patch could avoid warnning massage like in rk3288 platform:
> [    2.074764] dwc2 ff580000.usb: 256 invalid for
> host_perio_tx_fifo_size. Check HW configuration.
> 
> Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
> 
> ---
> 
>  drivers/usb/dwc2/core.c     | 2 +-
>  drivers/usb/dwc2/core.h     | 1 +
>  drivers/usb/dwc2/platform.c | 6 ++++++
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index c3cc1a7..86d1d65 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -474,7 +474,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg)
>   * Do core a soft reset of the core.  Be careful with this because it
>   * resets all the internal state machines of the core.
>   */
> -static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
> +int dwc2_core_reset(struct dwc2_hsotg *hsotg)
>  {
>  	u32 greset;
>  	int count = 0;
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 0ed87620..5d95aec 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -846,6 +846,7 @@ enum dwc2_halt_status {
>   * The following functions support initialization of the core driver component
>   * and the DWC_otg controller
>   */
> +extern int dwc2_core_reset(struct dwc2_hsotg *hsotg);
>  extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg);
>  extern int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg);
>  extern int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore);
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 9093530..8d3be4a 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -243,6 +243,12 @@ static int dwc2_driver_probe(struct platform_device *dev)
>  	spin_lock_init(&hsotg->lock);
>  	mutex_init(&hsotg->init_mutex);
>  
> +	/*
> +	 * Reset before dwc2_get_hwparams() then it could get power-on real
> +	 * reset value form registers.
> +	 */
> +	dwc2_core_reset(hsotg);
> +
>  	/* Detect config values from hardware */
>  	retval = dwc2_get_hwparams(hsotg);
>  	if (retval)
> 

Hi Yunzhi,

My concern is with the delays due to calling the dwc2_core_reset
during probe. You could factor out the assertion of the core
soft reset from the dwc2_core_reset and just use that before
calling dwc2_get_hwparams().

You had previously addressed the lengthy probe time issue here:
http://marc.info/?l=linux-usb&m=142357721304377

This reducing delays patch looks reasonable to me and I think it
should get merged also. I'll do some testing with it later this
week.

John



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-08-19  0:19 ` John Youn
@ 2015-10-01 20:50   ` Doug Anderson
  2015-10-05 22:02     ` John Youn
  0 siblings, 1 reply; 7+ messages in thread
From: Doug Anderson @ 2015-10-01 20:50 UTC (permalink / raw)
  To: John Youn
  Cc: Yunzhi Li, jwerner, huangtao, cf, hl, Greg Kroah-Hartman,
	linux-usb, linux-kernel

John,

On Tue, Aug 18, 2015 at 5:19 PM, John Youn <John.Youn@synopsys.com> wrote:
> Hi Yunzhi,
>
> My concern is with the delays due to calling the dwc2_core_reset
> during probe. You could factor out the assertion of the core
> soft reset from the dwc2_core_reset and just use that before
> calling dwc2_get_hwparams().
>
> You had previously addressed the lengthy probe time issue here:
> http://marc.info/?l=linux-usb&m=142357721304377
>
> This reducing delays patch looks reasonable to me and I think it
> should get merged also. I'll do some testing with it later this
> week.

Note: you can also avoid the extra reset during probe with something
like <https://chromium-review.googlesource.com/#/c/303152/>.  I'm
happy to post that up if you want, though it depends on lyz's patch.

...in Chrome OS we've also just landed lyz's patch to reduce delays.
If there's any fallout I'll report on the list.

-Doug

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-10-01 20:50   ` Doug Anderson
@ 2015-10-05 22:02     ` John Youn
  2015-10-08  0:50       ` Doug Anderson
  0 siblings, 1 reply; 7+ messages in thread
From: John Youn @ 2015-10-05 22:02 UTC (permalink / raw)
  To: Doug Anderson, John Youn
  Cc: Yunzhi Li, jwerner, huangtao, cf, hl, Greg Kroah-Hartman,
	linux-usb, linux-kernel

On 10/1/2015 1:50 PM, Doug Anderson wrote:
> John,
> 
> On Tue, Aug 18, 2015 at 5:19 PM, John Youn <John.Youn@synopsys.com> wrote:
>> Hi Yunzhi,
>>
>> My concern is with the delays due to calling the dwc2_core_reset
>> during probe. You could factor out the assertion of the core
>> soft reset from the dwc2_core_reset and just use that before
>> calling dwc2_get_hwparams().
>>
>> You had previously addressed the lengthy probe time issue here:
>> http://marc.info/?l=linux-usb&m=142357721304377
>>
>> This reducing delays patch looks reasonable to me and I think it
>> should get merged also. I'll do some testing with it later this
>> week.
> 
> Note: you can also avoid the extra reset during probe with something
> like <https://chromium-review.googlesource.com/#/c/303152/>.  I'm
> happy to post that up if you want, though it depends on lyz's patch.
> 
> ...in Chrome OS we've also just landed lyz's patch to reduce delays.
> If there's any fallout I'll report on the list.
> 
> -Doug
> 


Yes, I appreciate if you could submit that. I'd like to merge lyz's
reduce delays, lyz's bug fix for hwparams, and your fix for double
reset.

The gadget side will also need something similar which I can do if
needed. Do you guys run gadget mode?

Regards,
John


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-10-05 22:02     ` John Youn
@ 2015-10-08  0:50       ` Doug Anderson
  2015-10-09 21:19         ` John Youn
  0 siblings, 1 reply; 7+ messages in thread
From: Doug Anderson @ 2015-10-08  0:50 UTC (permalink / raw)
  To: John Youn
  Cc: Yunzhi Li, jwerner, huangtao, cf, hl, Greg Kroah-Hartman,
	linux-usb, linux-kernel

John,

On Mon, Oct 5, 2015 at 3:02 PM, John Youn <John.Youn@synopsys.com> wrote:
> On 10/1/2015 1:50 PM, Doug Anderson wrote:
>> John,
>>
>> On Tue, Aug 18, 2015 at 5:19 PM, John Youn <John.Youn@synopsys.com> wrote:
>>> Hi Yunzhi,
>>>
>>> My concern is with the delays due to calling the dwc2_core_reset
>>> during probe. You could factor out the assertion of the core
>>> soft reset from the dwc2_core_reset and just use that before
>>> calling dwc2_get_hwparams().
>>>
>>> You had previously addressed the lengthy probe time issue here:
>>> http://marc.info/?l=linux-usb&m=142357721304377
>>>
>>> This reducing delays patch looks reasonable to me and I think it
>>> should get merged also. I'll do some testing with it later this
>>> week.
>>
>> Note: you can also avoid the extra reset during probe with something
>> like <https://chromium-review.googlesource.com/#/c/303152/>.  I'm
>> happy to post that up if you want, though it depends on lyz's patch.
>>
>> ...in Chrome OS we've also just landed lyz's patch to reduce delays.
>> If there's any fallout I'll report on the list.
>>
>> -Doug
>>
>
>
> Yes, I appreciate if you could submit that. I'd like to merge lyz's
> reduce delays, lyz's bug fix for hwparams, and your fix for double
> reset.

OK, I've posted things up.  Let me know what you think.  Note that I
took v2 of lyz's patch (not v3) since I liked it better.


> The gadget side will also need something similar which I can do if
> needed. Do you guys run gadget mode?

I don't personally run in gadget mode.  I think it's possible to get
rk3288 to do it on one of the two ports, but I don't have it setup.


-Doug

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams()
  2015-10-08  0:50       ` Doug Anderson
@ 2015-10-09 21:19         ` John Youn
  0 siblings, 0 replies; 7+ messages in thread
From: John Youn @ 2015-10-09 21:19 UTC (permalink / raw)
  To: Doug Anderson, John Youn
  Cc: Yunzhi Li, jwerner, huangtao, cf, hl, Greg Kroah-Hartman,
	linux-usb, linux-kernel

On 10/7/2015 5:50 PM, Doug Anderson wrote:
> John,
> 
> On Mon, Oct 5, 2015 at 3:02 PM, John Youn <John.Youn@synopsys.com> wrote:
>> On 10/1/2015 1:50 PM, Doug Anderson wrote:
>>> John,
>>>
>>> On Tue, Aug 18, 2015 at 5:19 PM, John Youn <John.Youn@synopsys.com> wrote:
>>>> Hi Yunzhi,
>>>>
>>>> My concern is with the delays due to calling the dwc2_core_reset
>>>> during probe. You could factor out the assertion of the core
>>>> soft reset from the dwc2_core_reset and just use that before
>>>> calling dwc2_get_hwparams().
>>>>
>>>> You had previously addressed the lengthy probe time issue here:
>>>> http://marc.info/?l=linux-usb&m=142357721304377
>>>>
>>>> This reducing delays patch looks reasonable to me and I think it
>>>> should get merged also. I'll do some testing with it later this
>>>> week.
>>>
>>> Note: you can also avoid the extra reset during probe with something
>>> like <https://chromium-review.googlesource.com/#/c/303152/>.  I'm
>>> happy to post that up if you want, though it depends on lyz's patch.
>>>
>>> ...in Chrome OS we've also just landed lyz's patch to reduce delays.
>>> If there's any fallout I'll report on the list.
>>>
>>> -Doug
>>>
>>
>>
>> Yes, I appreciate if you could submit that. I'd like to merge lyz's
>> reduce delays, lyz's bug fix for hwparams, and your fix for double
>> reset.
> 
> OK, I've posted things up.  Let me know what you think.  Note that I
> took v2 of lyz's patch (not v3) since I liked it better.
> 
> 
>> The gadget side will also need something similar which I can do if
>> needed. Do you guys run gadget mode?
> 
> I don't personally run in gadget mode.  I think it's possible to get
> rk3288 to do it on one of the two ports, but I don't have it setup.
> 

No problem. I can make the gadget changes.

Thanks for submitting this.

Regards,
John


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-09 21:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18  9:40 [PATCH v2] usb: dwc2: reset dwc2 core before dwc2_get_hwparams() Yunzhi Li
2015-08-18 23:03 ` Doug Anderson
2015-08-19  0:19 ` John Youn
2015-10-01 20:50   ` Doug Anderson
2015-10-05 22:02     ` John Youn
2015-10-08  0:50       ` Doug Anderson
2015-10-09 21:19         ` John Youn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.