All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
@ 2015-04-06 14:05 Tim Harvey
  2015-04-06 14:58 ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Tim Harvey @ 2015-04-06 14:05 UTC (permalink / raw)
  To: u-boot

Some USB devices break the spec and require longer warm-up times. Allow
the usb_pgood_delay env variable to override the calculated time.

I have encountered this specficically with several different sized/branded USB
sticks with VID:PID 058f:6387 (Alcor Micro Corp. Transcend JetFlash) where I
need to set usb_pgood_delay to 2000ms to make them detectable.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 common/usb_hub.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 66b4a72..a0ef058 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -86,6 +86,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	int i;
 	struct usb_device *dev;
 	unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
+	const char *env;
 
 	dev = hub->pusb_dev;
 
@@ -98,7 +99,13 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	/*
 	 * Wait for power to become stable,
 	 * plus spec-defined max time for device to connect
+	 * but allow this time to be increased via env variable as some
+	 * devices break the spec and require longer warm-up times
 	 */
+	env = getenv("usb_pgood_delay");
+	if (env)
+		pgood_delay = max(pgood_delay, simple_strtol(env, NULL, 0));
+	debug("pgood_delay=%dms\n", pgood_delay);
 	mdelay(pgood_delay + 1000);
 }
 
-- 
1.9.1

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-06 14:05 [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env Tim Harvey
@ 2015-04-06 14:58 ` Marek Vasut
  2015-04-07 14:52   ` Tim Harvey
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2015-04-06 14:58 UTC (permalink / raw)
  To: u-boot

On Monday, April 06, 2015 at 04:05:07 PM, Tim Harvey wrote:
> Some USB devices break the spec and require longer warm-up times. Allow
> the usb_pgood_delay env variable to override the calculated time.
> 
> I have encountered this specficically with several different sized/branded
> USB sticks with VID:PID 058f:6387 (Alcor Micro Corp. Transcend JetFlash)
> where I need to set usb_pgood_delay to 2000ms to make them detectable.
> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

Hi!

this looks like a good idea. I have a hint for improvement -- in case you
get a timeout waiting for the device to be detected, maybe the error message
should mention that you can try setting this env variable and try again ?

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-06 14:58 ` Marek Vasut
@ 2015-04-07 14:52   ` Tim Harvey
  2015-04-07 15:34     ` Stephen Warren
  0 siblings, 1 reply; 10+ messages in thread
From: Tim Harvey @ 2015-04-07 14:52 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 6, 2015 at 7:58 AM, Marek Vasut <marex@denx.de> wrote:
> On Monday, April 06, 2015 at 04:05:07 PM, Tim Harvey wrote:
>> Some USB devices break the spec and require longer warm-up times. Allow
>> the usb_pgood_delay env variable to override the calculated time.
>>
>> I have encountered this specficically with several different sized/branded
>> USB sticks with VID:PID 058f:6387 (Alcor Micro Corp. Transcend JetFlash)
>> where I need to set usb_pgood_delay to 2000ms to make them detectable.
>>
>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>
> Hi!
>
> this looks like a good idea. I have a hint for improvement -- in case you
> get a timeout waiting for the device to be detected, maybe the error message
> should mention that you can try setting this env variable and try again ?
>
> Best regards,
> Marek Vasut

Marek,

I'm not sure what 'failed detect' would be appropriate though. In my
case I was dealing with storage devices so I think what you are
proposing is that on a 'usb start' if 0 storage devices are found
display a message such as:

No storage devices found - if a connected device is not being detected
try setting usb_pgood_delay env var to something above the 1000ms time
the USB spec allows

Sounds a bit verbose and I'm not clear if it should be limited to USB
storage devices or other supported devices (I'm betting its just the
storage ones that often break the spec).

Stephen, what do you think? You and I discussed adding such an env var
about a year ago.

Tim

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-07 14:52   ` Tim Harvey
@ 2015-04-07 15:34     ` Stephen Warren
  2015-04-07 16:04       ` Tim Harvey
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Warren @ 2015-04-07 15:34 UTC (permalink / raw)
  To: u-boot

On 04/07/2015 08:52 AM, Tim Harvey wrote:
> On Mon, Apr 6, 2015 at 7:58 AM, Marek Vasut <marex@denx.de> wrote:
>> On Monday, April 06, 2015 at 04:05:07 PM, Tim Harvey wrote:
>>> Some USB devices break the spec and require longer warm-up times. Allow
>>> the usb_pgood_delay env variable to override the calculated time.
>>>
>>> I have encountered this specficically with several different sized/branded
>>> USB sticks with VID:PID 058f:6387 (Alcor Micro Corp. Transcend JetFlash)
>>> where I need to set usb_pgood_delay to 2000ms to make them detectable.
>>>
>>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>>
>> Hi!
>>
>> this looks like a good idea. I have a hint for improvement -- in case you
>> get a timeout waiting for the device to be detected, maybe the error message
>> should mention that you can try setting this env variable and try again ?
>>
>> Best regards,
>> Marek Vasut
>
> Marek,
>
> I'm not sure what 'failed detect' would be appropriate though. In my
> case I was dealing with storage devices so I think what you are
> proposing is that on a 'usb start' if 0 storage devices are found
> display a message such as:
>
> No storage devices found - if a connected device is not being detected
> try setting usb_pgood_delay env var to something above the 1000ms time
> the USB spec allows

That seems like something better for the documentation that at run-time. 
There's no reason to believe that the user has any USB storage devices 
plugged in.

> Sounds a bit verbose and I'm not clear if it should be limited to USB
> storage devices or other supported devices (I'm betting its just the
> storage ones that often break the spec).
>
> Stephen, what do you think? You and I discussed adding such an env var
> about a year ago.

If there is some kind of error that's actively detected, it may make 
sense to print some kind of message. However, if the symptoms are that 
devices simply don't appear on the bus and there's no reason to believe 
any are actually plugged in, that fells different.

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-07 15:34     ` Stephen Warren
@ 2015-04-07 16:04       ` Tim Harvey
  2015-04-07 18:55         ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Tim Harvey @ 2015-04-07 16:04 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 7, 2015 at 8:34 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 04/07/2015 08:52 AM, Tim Harvey wrote:
>>
>> On Mon, Apr 6, 2015 at 7:58 AM, Marek Vasut <marex@denx.de> wrote:
>>>
>>> On Monday, April 06, 2015 at 04:05:07 PM, Tim Harvey wrote:
>>>>
>>>> Some USB devices break the spec and require longer warm-up times. Allow
>>>> the usb_pgood_delay env variable to override the calculated time.
>>>>
>>>> I have encountered this specficically with several different
>>>> sized/branded
>>>> USB sticks with VID:PID 058f:6387 (Alcor Micro Corp. Transcend JetFlash)
>>>> where I need to set usb_pgood_delay to 2000ms to make them detectable.
>>>>
>>>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>>>
>>>
>>> Hi!
>>>
>>> this looks like a good idea. I have a hint for improvement -- in case you
>>> get a timeout waiting for the device to be detected, maybe the error
>>> message
>>> should mention that you can try setting this env variable and try again ?
>>>
>>> Best regards,
>>> Marek Vasut
>>
>>
>> Marek,
>>
>> I'm not sure what 'failed detect' would be appropriate though. In my
>> case I was dealing with storage devices so I think what you are
>> proposing is that on a 'usb start' if 0 storage devices are found
>> display a message such as:
>>
>> No storage devices found - if a connected device is not being detected
>> try setting usb_pgood_delay env var to something above the 1000ms time
>> the USB spec allows
>
>
> That seems like something better for the documentation that at run-time.
> There's no reason to believe that the user has any USB storage devices
> plugged in.
>
>> Sounds a bit verbose and I'm not clear if it should be limited to USB
>> storage devices or other supported devices (I'm betting its just the
>> storage ones that often break the spec).
>>
>> Stephen, what do you think? You and I discussed adding such an env var
>> about a year ago.
>
>
> If there is some kind of error that's actively detected, it may make sense
> to print some kind of message. However, if the symptoms are that devices
> simply don't appear on the bus and there's no reason to believe any are
> actually plugged in, that fells different.

No error... just failure to detect storage device. I agree such a
message for people using 'usb start' for some other usb device is not
cool.

Let's leave it as-is then if there are no complaints.

Tim

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-07 16:04       ` Tim Harvey
@ 2015-04-07 18:55         ` Marek Vasut
  2015-04-08 16:50           ` Tim Harvey
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2015-04-07 18:55 UTC (permalink / raw)
  To: u-boot

On Tuesday, April 07, 2015 at 06:04:36 PM, Tim Harvey wrote:
[...]

> > If there is some kind of error that's actively detected, it may make
> > sense to print some kind of message. However, if the symptoms are that
> > devices simply don't appear on the bus and there's no reason to believe
> > any are actually plugged in, that fells different.
> 
> No error... just failure to detect storage device. I agree such a
> message for people using 'usb start' for some other usb device is not
> cool.
> 
> Let's leave it as-is then if there are no complaints.

Hi,

Is the device recognised on the bus and just not identified OR is the device
not even recognised on the bus ?

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env
  2015-04-07 18:55         ` Marek Vasut
@ 2015-04-08 16:50           ` Tim Harvey
  2015-04-08 19:21             ` [U-Boot] [PATCH v2] " Tim Harvey
  0 siblings, 1 reply; 10+ messages in thread
From: Tim Harvey @ 2015-04-08 16:50 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 7, 2015 at 11:55 AM, Marek Vasut <marex@denx.de> wrote:
> On Tuesday, April 07, 2015 at 06:04:36 PM, Tim Harvey wrote:
> [...]
>
>> > If there is some kind of error that's actively detected, it may make
>> > sense to print some kind of message. However, if the symptoms are that
>> > devices simply don't appear on the bus and there's no reason to believe
>> > any are actually plugged in, that fells different.
>>
>> No error... just failure to detect storage device. I agree such a
>> message for people using 'usb start' for some other usb device is not
>> cool.
>>
>> Let's leave it as-is then if there are no complaints.
>
> Hi,
>
> Is the device recognised on the bus and just not identified OR is the device
> not even recognised on the bus ?
>
> Best regards,
> Marek Vasut

Marek,

No timeout - just failure to see Port status change
(portstatus/portchange reflect no change on port).

I did notice there is a compiler warning with my patch that I missed
so I'll re-post it with that resolved if everything else looks ok.

Tim

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

* [U-Boot] [PATCH v2] usb: hub: allow pgood_delay to be specified via env
  2015-04-08 16:50           ` Tim Harvey
@ 2015-04-08 19:21             ` Tim Harvey
  2015-04-11 16:59               ` Marek Vasut
  2015-04-11 17:08               ` Marek Vasut
  0 siblings, 2 replies; 10+ messages in thread
From: Tim Harvey @ 2015-04-08 19:21 UTC (permalink / raw)
  To: u-boot

Some USB devices break the spec and require longer warm-up times. Allow
the usb_pgood_delay env variable to override the calculated time.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
v2:
 - added cast to fix compiler warning
---
 common/usb_hub.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 66b4a72..f54a404 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -86,6 +86,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	int i;
 	struct usb_device *dev;
 	unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
+	const char *env;
 
 	dev = hub->pusb_dev;
 
@@ -98,7 +99,14 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	/*
 	 * Wait for power to become stable,
 	 * plus spec-defined max time for device to connect
+	 * but allow this time to be increased via env variable as some
+	 * devices break the spec and require longer warm-up times
 	 */
+	env = getenv("usb_pgood_delay");
+	if (env)
+		pgood_delay = max(pgood_delay,
+			          (unsigned)simple_strtol(env, NULL, 0));
+	debug("pgood_delay=%dms\n", pgood_delay);
 	mdelay(pgood_delay + 1000);
 }
 
-- 
1.9.1

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

* [U-Boot] [PATCH v2] usb: hub: allow pgood_delay to be specified via env
  2015-04-08 19:21             ` [U-Boot] [PATCH v2] " Tim Harvey
@ 2015-04-11 16:59               ` Marek Vasut
  2015-04-11 17:08               ` Marek Vasut
  1 sibling, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2015-04-11 16:59 UTC (permalink / raw)
  To: u-boot

On Wednesday, April 08, 2015 at 09:21:12 PM, Tim Harvey wrote:
> Some USB devices break the spec and require longer warm-up times. Allow
> the usb_pgood_delay env variable to override the calculated time.
> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

It'd be nice if this variable was documented somewhere. Can you please
do that ? Subsequent patch would be fine, though I'm not sure where exactly
to place such documentation. Any ideas ?

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH v2] usb: hub: allow pgood_delay to be specified via env
  2015-04-08 19:21             ` [U-Boot] [PATCH v2] " Tim Harvey
  2015-04-11 16:59               ` Marek Vasut
@ 2015-04-11 17:08               ` Marek Vasut
  1 sibling, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2015-04-11 17:08 UTC (permalink / raw)
  To: u-boot

On Wednesday, April 08, 2015 at 09:21:12 PM, Tim Harvey wrote:
> Some USB devices break the spec and require longer warm-up times. Allow
> the usb_pgood_delay env variable to override the calculated time.
> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

Applied to u-boot-usb/next , thanks!

Best regards,
Marek Vasut

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

end of thread, other threads:[~2015-04-11 17:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 14:05 [U-Boot] [PATCH] usb: hub: allow pgood_delay to be specified via env Tim Harvey
2015-04-06 14:58 ` Marek Vasut
2015-04-07 14:52   ` Tim Harvey
2015-04-07 15:34     ` Stephen Warren
2015-04-07 16:04       ` Tim Harvey
2015-04-07 18:55         ` Marek Vasut
2015-04-08 16:50           ` Tim Harvey
2015-04-08 19:21             ` [U-Boot] [PATCH v2] " Tim Harvey
2015-04-11 16:59               ` Marek Vasut
2015-04-11 17:08               ` Marek Vasut

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.