Skip to contentSkip to conversation

usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

PATCH New Alex Kiernan 2 participants 6 messages Dec 7, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

Make the timeout in musb_lowlevel_init() configurable from the 1s default. Some USB memory sticks take longer than 1s to connect and so whilst usable in Linux aren't usable in U-Boot. The default in Kconfig is still 1000ms, so this should be a non-change for any existing users.

---

 drivers/usb/musb-new/Kconfig      | 8 ++++++++
 drivers/usb/musb-new/musb_uboot.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/usb/musb-new/Kconfig +8 -0
index f8f2205a62d3..5b9df5227961 100644
@@ -54,6 +54,14 @@ config USB_MUSB_SUNXI
 	Say y here to enable support for the sunxi OTG / DRC USB controller
 	used on almost all sunxi boards.
 
+config USB_MUSB_INIT_TIMEOUT
+	int "Low level initialization timeout"
+	default 1000
+	help
+	  The USB spec says it may take up to 1 second for a device to
+	  connect. Some devices take longer than this to connect, so
+	  you can increase the timeout here. The value here is in ms.
+
 endif
 
 config USB_MUSB_PIO_ONLY
drivers/usb/musb-new/musb_uboot.c +1 -1
index d40772b1aa5c..82591ad8f6b5 100644
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
 	void *mbase;
 	/* USB spec says it may take up to 1 second for a device to connect */
-	unsigned long timeout = get_timer(0) + 1000;
+	unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;
 	int ret;
 
 	if (!host->host) {
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

On 12/07/2018 09:56 AM, Alex Kiernan wrote:
[...]

drivers/usb/musb-new/musb_uboot.c int musb_lowlevel_init(struct musb_host_data *host) · line 217

Quoted 7 lines

+++ b/drivers/usb/musb-new/musb_uboot.c

drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
 	void *mbase;
 	/* USB spec says it may take up to 1 second for a device to connect */
-	unsigned long timeout = get_timer(0) + 1000;
+	unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;

Isn't this the same as usb_pgood_delay ?

Quoted 4 lines
drivers/usb/musb-new/musb_uboot.c +0 -0
 	int ret;
 
 	if (!host->host) {
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

Quoted 13 lines · Marek Vasut

On 12/07/2018 09:56 AM, Alex Kiernan wrote:
[...]

drivers/usb/musb-new/musb_uboot.c int musb_lowlevel_init(struct musb_host_data *host) · line 217

Quoted 7 lines

+++ b/drivers/usb/musb-new/musb_uboot.c

drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
      void *mbase;
      /* USB spec says it may take up to 1 second for a device to connect */
-     unsigned long timeout = get_timer(0) + 1000;
+     unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;

Isn't this the same as usb_pgood_delay ?

Looks like it; I'll spin a v2 which uses that.

Signature · 1 line
Alex Kiernan
#3 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

Quoted 15 lines · Alex Kiernan
Quoted 13 lines · Marek Vasut

On 12/07/2018 09:56 AM, Alex Kiernan wrote:
[...]

drivers/usb/musb-new/musb_uboot.c int musb_lowlevel_init(struct musb_host_data *host) · line 217

Quoted 7 lines

+++ b/drivers/usb/musb-new/musb_uboot.c

drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
      void *mbase;
      /* USB spec says it may take up to 1 second for a device to connect */
-     unsigned long timeout = get_timer(0) + 1000;
+     unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;

Isn't this the same as usb_pgood_delay ?

Quoted 1 line

Looks like it; I'll spin a v2 which uses that.

I wonder if this code is needed at all, shouldn't the USB core deal with this delay ?

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

Quoted 17 lines · Marek Vasut
Quoted 15 lines · Alex Kiernan
Quoted 13 lines · Marek Vasut

On 12/07/2018 09:56 AM, Alex Kiernan wrote:
[...]

drivers/usb/musb-new/musb_uboot.c int musb_lowlevel_init(struct musb_host_data *host) · line 217

Quoted 7 lines

+++ b/drivers/usb/musb-new/musb_uboot.c

drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
      void *mbase;
      /* USB spec says it may take up to 1 second for a device to connect */
-     unsigned long timeout = get_timer(0) + 1000;
+     unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;

Isn't this the same as usb_pgood_delay ?

Quoted 5 lines
Quoted 1 line

Looks like it; I'll spin a v2 which uses that.

I wonder if this code is needed at all, shouldn't the USB core deal with this delay ?

Oh I see... certainly I can't just take that delay out, that just ends up at:

USB0: scanning bus 0 for devices... USB device descriptor short read
(expected 8, got 0)
failed, error -5

Certainly without that delay, there's clearly delays in the rest of the USB core, so I expect you're right, I just don't know where to put the poll for MUSB_DEVCTL_HM.

Signature · 1 line
Alex Kiernan
#5 lore raw

PATCH 1/1 usb: musb-new: Add CONFIG_USB_MUSB_INIT_TIMEOUT

Quoted 26 lines · Alex Kiernan
Quoted 17 lines · Marek Vasut
Quoted 15 lines · Alex Kiernan
Quoted 13 lines · Marek Vasut

On 12/07/2018 09:56 AM, Alex Kiernan wrote:
[...]

drivers/usb/musb-new/musb_uboot.c int musb_lowlevel_init(struct musb_host_data *host) · line 217

Quoted 7 lines

+++ b/drivers/usb/musb-new/musb_uboot.c

drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -214,7 +214,7 @@ int musb_lowlevel_init(struct musb_host_data *host)
 {
      void *mbase;
      /* USB spec says it may take up to 1 second for a device to connect */
-     unsigned long timeout = get_timer(0) + 1000;
+     unsigned long timeout = get_timer(0) + CONFIG_USB_MUSB_INIT_TIMEOUT;

Isn't this the same as usb_pgood_delay ?

Quoted 5 lines
Quoted 1 line

Looks like it; I'll spin a v2 which uses that.

I wonder if this code is needed at all, shouldn't the USB core deal with this delay ?

Oh I see... certainly I can't just take that delay out, that just ends up at:

Quoted 7 lines

USB0: scanning bus 0 for devices... USB device descriptor short read
(expected 8, got 0)
failed, error -5

Certainly without that delay, there's clearly delays in the rest of the USB core, so I expect you're right, I just don't know where to put the poll for MUSB_DEVCTL_HM.

Can you research it a bit ? What does the _HM bit do ?

Signature · 2 lines
Best regards,
Marek Vasut