public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] davinci, dm365, usb: timeoutvalue
@ 2011-07-06 11:29 Heiko Schocher
  2011-07-06 14:06 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Schocher @ 2011-07-06 11:29 UTC (permalink / raw)
  To: u-boot

Hello Thomas,

I just debugging some usb issues on an dm365 based board. I noticed
that if no usb device is connected to the board, the "usb start"
command does have a long timeout (also have access to an dm365evm
board, same behaviour). Found the reason for this big timeout here:

./drivers/usb/musb/musb_hcd.c usb_lowlevel_init():
	timeout = musb_cfg.timeout;
        while (timeout--)
                if (readb(&musbr->devctl) & MUSB_DEVCTL_HM)
                        break;


with ./drivers/usb/musb/davinci.:
/* MUSB platform configuration */
struct musb_config musb_cfg = {
        .regs           = (struct musb_regs *)MENTOR_USB0_BASE,
        .timeout        = DAVINCI_USB_TIMEOUT,
        .musb_speed     = 0,
};

and ./drivers/usb/musb/davinci.h:

#define DAVINCI_USB_TIMEOUT 0x3FFFFFF

Why is this DAVINCI_USB_TIMEOUT value so high? This could be shorter,
or are there some reasons for such a long timeout?

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] davinci, dm365, usb: timeoutvalue
  2011-07-06 11:29 [U-Boot] davinci, dm365, usb: timeoutvalue Heiko Schocher
@ 2011-07-06 14:06 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2011-07-06 14:06 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

In message <4E144710.7020807@denx.de> you wrote:
> Hello Thomas,
> 
> I just debugging some usb issues on an dm365 based board. I noticed
> that if no usb device is connected to the board, the "usb start"
> command does have a long timeout (also have access to an dm365evm
> board, same behaviour). Found the reason for this big timeout here:
> 
> ./drivers/usb/musb/musb_hcd.c usb_lowlevel_init():
> 	timeout = musb_cfg.timeout;
>         while (timeout--)
>                 if (readb(&musbr->devctl) & MUSB_DEVCTL_HM)
>                         break;

Argh...

> #define DAVINCI_USB_TIMEOUT 0x3FFFFFF
> 
> Why is this DAVINCI_USB_TIMEOUT value so high? This could be shorter,
> or are there some reasons for such a long timeout?

Actually this means that the actual amount of time spent in this loop
is not defined, and depends on the actual speed of the CPU, RAM, etc.

The timeout value should be changed into a time value (instead of
cycle count), and the poll loop should be changed accordingly, for
example like this:

	#define DAVINCI_USB_TIMEOUT 250		/* 250 milliseconds */

	...
	while (timeout--) {
		if (readb(&musbr->devctl) & MUSB_DEVCTL_HM)
			break;
		udelay (1000);
	}


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Today's robots are very primitive, capable of understanding  only  a
few  simple  instructions  such  as 'go left', 'go right', and 'build
car'."                                                  - John Sladek

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

end of thread, other threads:[~2011-07-06 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-06 11:29 [U-Boot] davinci, dm365, usb: timeoutvalue Heiko Schocher
2011-07-06 14:06 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox