linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: dwc2: reset AHB hclk domain before init
@ 2015-08-11  2:27 Yunzhi Li
  2015-08-11 14:12 ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Yunzhi Li @ 2015-08-11  2:27 UTC (permalink / raw)
  To: jwerner, dianders
  Cc: huangtao, cf, hl, linux-rockchip, Yunzhi Li, John Youn,
	Greg Kroah-Hartman, linux-usb, linux-kernel

We initiate dwc2 usb controller in BIOS, when kernel driver
start-up we should reset AHB hclk domain to reset all AHB
interface registers to default. Without this the FIFO value
setting might be incorrect because calculating FIFO size need the
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/platform.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 9093530..3da21ab 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -42,6 +42,7 @@
 #include <linux/of_device.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 
 #include <linux/usb/of.h>
 
@@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
 	struct resource *res;
 	struct phy *phy;
 	struct usb_phy *uphy;
+	struct reset_control *rst;
 	int retval;
 	int irq;
 
@@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
 
 	hsotg->dev = &dev->dev;
 
+	/* AHB hclk domain reset, set all AHB interface registers to default */
+	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");
+	if (IS_ERR(rst)) {
+		dev_dbg(&dev->dev, "Can't get dwc2 AHB reset\n");
+	} else {
+		reset_control_assert(rst);
+		udelay(5);
+		reset_control_deassert(rst);
+	}
+
 	/*
 	 * Use reasonable defaults so platforms don't have to provide these.
 	 */
-- 
2.0.0



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

* Re: [PATCH v1] usb: dwc2: reset AHB hclk domain before init
  2015-08-11  2:27 [PATCH v1] usb: dwc2: reset AHB hclk domain before init Yunzhi Li
@ 2015-08-11 14:12 ` Felipe Balbi
  2015-08-12 11:06   ` Yunzhi Li
  0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2015-08-11 14:12 UTC (permalink / raw)
  To: Yunzhi Li
  Cc: jwerner, dianders, huangtao, cf, hl, linux-rockchip, John Youn,
	Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

Hi,

On Tue, Aug 11, 2015 at 10:27:42AM +0800, Yunzhi Li wrote:
> We initiate dwc2 usb controller in BIOS, when kernel driver
> start-up we should reset AHB hclk domain to reset all AHB
> interface registers to default. Without this the FIFO value
> setting might be incorrect because calculating FIFO size need the
> 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/platform.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 9093530..3da21ab 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -42,6 +42,7 @@
>  #include <linux/of_device.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>
> +#include <linux/reset.h>
>  
>  #include <linux/usb/of.h>
>  
> @@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
>  	struct resource *res;
>  	struct phy *phy;
>  	struct usb_phy *uphy;
> +	struct reset_control *rst;
>  	int retval;
>  	int irq;
>  
> @@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
>  
>  	hsotg->dev = &dev->dev;
>  
> +	/* AHB hclk domain reset, set all AHB interface registers to default */
> +	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");

why isn't this done in core so PCI systems can also make use of it ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v1] usb: dwc2: reset AHB hclk domain before init
  2015-08-11 14:12 ` Felipe Balbi
@ 2015-08-12 11:06   ` Yunzhi Li
  2015-08-12 19:32     ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Yunzhi Li @ 2015-08-12 11:06 UTC (permalink / raw)
  To: balbi
  Cc: jwerner, dianders, huangtao, cf, hl, linux-rockchip, John Youn,
	Greg Kroah-Hartman, linux-usb, linux-kernel

Hi ,
在 2015/8/11 22:12, Felipe Balbi 写道:
> Hi,
>
> On Tue, Aug 11, 2015 at 10:27:42AM +0800, Yunzhi Li wrote:
>> We initiate dwc2 usb controller in BIOS, when kernel driver
>> start-up we should reset AHB hclk domain to reset all AHB
>> interface registers to default. Without this the FIFO value
>> setting might be incorrect because calculating FIFO size need the
>> 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/platform.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
>> index 9093530..3da21ab 100644
>> --- a/drivers/usb/dwc2/platform.c
>> +++ b/drivers/usb/dwc2/platform.c
>> @@ -42,6 +42,7 @@
>>   #include <linux/of_device.h>
>>   #include <linux/mutex.h>
>>   #include <linux/platform_device.h>
>> +#include <linux/reset.h>
>>   
>>   #include <linux/usb/of.h>
>>   
>> @@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
>>   	struct resource *res;
>>   	struct phy *phy;
>>   	struct usb_phy *uphy;
>> +	struct reset_control *rst;
>>   	int retval;
>>   	int irq;
>>   
>> @@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
>>   
>>   	hsotg->dev = &dev->dev;
>>   
>> +	/* AHB hclk domain reset, set all AHB interface registers to default */
>> +	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");
> why isn't this done in core so PCI systems can also make use of it ?
>
I have no ides about how to reset a PCI interface dwc2 controller, John 
could you please give some infomation about it ?
Is it also needed for PCI interface dwc2 IP ?


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

* Re: [PATCH v1] usb: dwc2: reset AHB hclk domain before init
  2015-08-12 11:06   ` Yunzhi Li
@ 2015-08-12 19:32     ` Felipe Balbi
  2015-08-13  8:37       ` John Youn
  0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2015-08-12 19:32 UTC (permalink / raw)
  To: Yunzhi Li
  Cc: balbi, jwerner, dianders, huangtao, cf, hl, linux-rockchip,
	John Youn, Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2126 bytes --]

On Wed, Aug 12, 2015 at 07:06:09PM +0800, Yunzhi Li wrote:
> Hi ,
> 在 2015/8/11 22:12, Felipe Balbi 写道:
> >Hi,
> >
> >On Tue, Aug 11, 2015 at 10:27:42AM +0800, Yunzhi Li wrote:
> >>We initiate dwc2 usb controller in BIOS, when kernel driver
> >>start-up we should reset AHB hclk domain to reset all AHB
> >>interface registers to default. Without this the FIFO value
> >>setting might be incorrect because calculating FIFO size need the
> >>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/platform.c | 12 ++++++++++++
> >>  1 file changed, 12 insertions(+)
> >>
> >>diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> >>index 9093530..3da21ab 100644
> >>--- a/drivers/usb/dwc2/platform.c
> >>+++ b/drivers/usb/dwc2/platform.c
> >>@@ -42,6 +42,7 @@
> >>  #include <linux/of_device.h>
> >>  #include <linux/mutex.h>
> >>  #include <linux/platform_device.h>
> >>+#include <linux/reset.h>
> >>  #include <linux/usb/of.h>
> >>@@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
> >>  	struct resource *res;
> >>  	struct phy *phy;
> >>  	struct usb_phy *uphy;
> >>+	struct reset_control *rst;
> >>  	int retval;
> >>  	int irq;
> >>@@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
> >>  	hsotg->dev = &dev->dev;
> >>+	/* AHB hclk domain reset, set all AHB interface registers to default */
> >>+	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");
> >why isn't this done in core so PCI systems can also make use of it ?
> >
> I have no ides about how to reset a PCI interface dwc2 controller, John
> could you please give some infomation about it ?
> Is it also needed for PCI interface dwc2 IP ?

even on platform only, how do you know all users provide a ahb_reset
reset controller ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v1] usb: dwc2: reset AHB hclk domain before init
  2015-08-12 19:32     ` Felipe Balbi
@ 2015-08-13  8:37       ` John Youn
  2015-08-13 14:28         ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: John Youn @ 2015-08-13  8:37 UTC (permalink / raw)
  To: balbi, Yunzhi Li
  Cc: jwerner, dianders, huangtao, cf, hl, linux-rockchip, John Youn,
	Greg Kroah-Hartman, linux-usb, linux-kernel

On 8/12/2015 12:33 PM, Felipe Balbi wrote:
> On Wed, Aug 12, 2015 at 07:06:09PM +0800, Yunzhi Li wrote:
>> Hi ,
>> 在 2015/8/11 22:12, Felipe Balbi 写道:
>>> Hi,
>>>
>>> On Tue, Aug 11, 2015 at 10:27:42AM +0800, Yunzhi Li wrote:
>>>> We initiate dwc2 usb controller in BIOS, when kernel driver
>>>> start-up we should reset AHB hclk domain to reset all AHB
>>>> interface registers to default. Without this the FIFO value
>>>> setting might be incorrect because calculating FIFO size need the
>>>> 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/platform.c | 12 ++++++++++++
>>>>  1 file changed, 12 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
>>>> index 9093530..3da21ab 100644
>>>> --- a/drivers/usb/dwc2/platform.c
>>>> +++ b/drivers/usb/dwc2/platform.c
>>>> @@ -42,6 +42,7 @@
>>>>  #include <linux/of_device.h>
>>>>  #include <linux/mutex.h>
>>>>  #include <linux/platform_device.h>
>>>> +#include <linux/reset.h>
>>>>  #include <linux/usb/of.h>
>>>> @@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
>>>>  	struct resource *res;
>>>>  	struct phy *phy;
>>>>  	struct usb_phy *uphy;
>>>> +	struct reset_control *rst;
>>>>  	int retval;
>>>>  	int irq;
>>>> @@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
>>>>  	hsotg->dev = &dev->dev;
>>>> +	/* AHB hclk domain reset, set all AHB interface registers to default */
>>>> +	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");
>>> why isn't this done in core so PCI systems can also make use of it ?
>>>
>> I have no ides about how to reset a PCI interface dwc2 controller, John
>> could you please give some infomation about it ?
>> Is it also needed for PCI interface dwc2 IP ?
> 
> even on platform only, how do you know all users provide a ahb_reset
> reset controller ?
> 

Also where do you provide the ahb_reset? I don't see it as a
property for dwc2.

With regards to PCI, I'm also not sure how you'd accomplish
something like this. But the platform I use at least doesn't need
this.

Regards,
John






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

* Re: [PATCH v1] usb: dwc2: reset AHB hclk domain before init
  2015-08-13  8:37       ` John Youn
@ 2015-08-13 14:28         ` Felipe Balbi
  0 siblings, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2015-08-13 14:28 UTC (permalink / raw)
  To: John Youn
  Cc: balbi, Yunzhi Li, jwerner, dianders, huangtao, cf, hl,
	linux-rockchip, Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2753 bytes --]

On Thu, Aug 13, 2015 at 08:37:36AM +0000, John Youn wrote:
> On 8/12/2015 12:33 PM, Felipe Balbi wrote:
> > On Wed, Aug 12, 2015 at 07:06:09PM +0800, Yunzhi Li wrote:
> >> Hi ,
> >> 在 2015/8/11 22:12, Felipe Balbi 写道:
> >>> Hi,
> >>>
> >>> On Tue, Aug 11, 2015 at 10:27:42AM +0800, Yunzhi Li wrote:
> >>>> We initiate dwc2 usb controller in BIOS, when kernel driver
> >>>> start-up we should reset AHB hclk domain to reset all AHB
> >>>> interface registers to default. Without this the FIFO value
> >>>> setting might be incorrect because calculating FIFO size need the
> >>>> 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/platform.c | 12 ++++++++++++
> >>>>  1 file changed, 12 insertions(+)
> >>>>
> >>>> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> >>>> index 9093530..3da21ab 100644
> >>>> --- a/drivers/usb/dwc2/platform.c
> >>>> +++ b/drivers/usb/dwc2/platform.c
> >>>> @@ -42,6 +42,7 @@
> >>>>  #include <linux/of_device.h>
> >>>>  #include <linux/mutex.h>
> >>>>  #include <linux/platform_device.h>
> >>>> +#include <linux/reset.h>
> >>>>  #include <linux/usb/of.h>
> >>>> @@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
> >>>>  	struct resource *res;
> >>>>  	struct phy *phy;
> >>>>  	struct usb_phy *uphy;
> >>>> +	struct reset_control *rst;
> >>>>  	int retval;
> >>>>  	int irq;
> >>>> @@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
> >>>>  	hsotg->dev = &dev->dev;
> >>>> +	/* AHB hclk domain reset, set all AHB interface registers to default */
> >>>> +	rst = devm_reset_control_get_optional(&dev->dev, "ahb_reset");
> >>> why isn't this done in core so PCI systems can also make use of it ?
> >>>
> >> I have no ides about how to reset a PCI interface dwc2 controller, John
> >> could you please give some infomation about it ?
> >> Is it also needed for PCI interface dwc2 IP ?
> > 
> > even on platform only, how do you know all users provide a ahb_reset
> > reset controller ?
> > 
> 
> Also where do you provide the ahb_reset? I don't see it as a
> property for dwc2.
> 
> With regards to PCI, I'm also not sure how you'd accomplish
> something like this. But the platform I use at least doesn't need
> this.

Is the reset controller optional ? That _optional should always return a
valid pointer, right ? Even if that valid pointer is NULL :-)

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-08-13 14:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-11  2:27 [PATCH v1] usb: dwc2: reset AHB hclk domain before init Yunzhi Li
2015-08-11 14:12 ` Felipe Balbi
2015-08-12 11:06   ` Yunzhi Li
2015-08-12 19:32     ` Felipe Balbi
2015-08-13  8:37       ` John Youn
2015-08-13 14:28         ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).