[openfirmware] r1479 - dev/usb2/hcd/ehci

svn at openfirmware.info svn at openfirmware.info
Sat Nov 14 02:07:09 CET 2009


Author: wmb
Date: 2009-11-14 02:07:09 +0100 (Sat, 14 Nov 2009)
New Revision: 1479

Modified:
   dev/usb2/hcd/ehci/qhtd.fth
Log:
OLPC trac 9423 - Rearranged the EHCI qh-done? routine to make the
logic clearer and to add an initial delay before polling the queue
header.  Without that delay, USB probing fails.  I think this might
be a Via quirk, but I'm not sure.


Modified: dev/usb2/hcd/ehci/qhtd.fth
===================================================================
--- dev/usb2/hcd/ehci/qhtd.fth	2009-11-14 01:05:23 UTC (rev 1478)
+++ dev/usb2/hcd/ehci/qhtd.fth	2009-11-14 01:07:09 UTC (rev 1479)
@@ -538,6 +538,7 @@
    or					( done?' )
 ;
 
+: poll-delay  ( -- )  d# 50 " us" evaluate  ;
 : qh-done?  ( qh -- done? )
    process-hc-status          ( qh )
    dup sync-qh                ( qh )
@@ -545,19 +546,22 @@
 ;
 
 : done?  ( qh -- usberr )
-   begin
-      dup qh-done? ?dup 0=  if  ( qh )
-         1 ms
-         dup >qh-timeout	( qh timeout-adr )
-         dup l@ 1-		( qh timeout-adr timeout' )
-         dup rot l!		( qh timeout' )
-         0=                     ( qh timed-out? )
-         dup  if  " Timeout" USB_ERR_TIMEOUT set-usb-error  noop  then  ( qh timed-out? )
-      then                      ( qh exit-loop? )
-   until                        ( qh )
-   drop                         ( )
+   poll-delay  \ This may be a VIA quirk - if we poll too soon, we never see the done bit
+   begin  dup qh-done?  0=  while   ( qh )
+      1 ms
+      dup >qh-timeout	( qh timeout-adr )
+      dup l@ 1-		( qh timeout-adr timeout' )
+      dup rot l!	( qh timeout' )
+      0=  if            ( qh )
+         " Timeout" USB_ERR_TIMEOUT set-usb-error ( qh )
+         drop           ( )
+         usb-error      ( usberr )
+         exit
+      then
+   repeat               ( qh )
+   drop                 ( )
 
-   usb-error
+   usb-error		( usberr )
 ;
 
 : qtd-error?  ( qtd qh -- usberr )




More information about the openfirmware mailing list