[openfirmware] [commit] r2233 - cpu/arm/olpc/1.75 dev/usb2 dev/usb2/device/hub dev/usb2/hcd dev/usb2/hcd/ehci

repository service svn at openfirmware.info
Fri May 27 04:16:26 CEST 2011


Author: wmb
Date: Fri May 27 04:16:25 2011
New Revision: 2233
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2233

Log:
OLPC trac #10887 - added selftest support for USB hubs.

Modified:
   cpu/arm/olpc/1.75/usb.fth
   dev/usb2/device/hub/hub.fth
   dev/usb2/hcd/ehci/probe.fth
   dev/usb2/hcd/ehci/qhtd.fth
   dev/usb2/hcd/hcd-call.fth
   dev/usb2/hcd/probehub.fth
   dev/usb2/pkt-data.fth

Modified: cpu/arm/olpc/1.75/usb.fth
==============================================================================
--- cpu/arm/olpc/1.75/usb.fth	Thu May 26 23:23:22 2011	(r2232)
+++ cpu/arm/olpc/1.75/usb.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -16,6 +16,9 @@
    : otg-set-host-mode  3 h# a8 ehci-reg!  ;  \ Force host mode
    ' otg-set-host-mode to set-host-mode
 
+   \ Port 1 on the hub (bit 0) is connected to unused pins on the
+   \ WLAN connector, so testing it is confusing
+   h# e  " hub-port-mask" integer-property
 end-package
    
 d# 300 config-int usb-delay  \ Milliseconds to wait before probing hub ports

Modified: dev/usb2/device/hub/hub.fth
==============================================================================
--- dev/usb2/device/hub/hub.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/device/hub/hub.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -53,6 +53,11 @@
       reprobe-hub-xt execute
    then
 ;
+: selftest  ( -- )
+   ['] hub-id catch 0=  if
+      hub-selftest-xt execute
+   then
+;
 
 probe-hub
 

Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/hcd/ehci/probe.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -60,9 +60,10 @@
    then                                              ( #testable-ports )
 ;
 
+: port-connected?  ( port# -- flag )  portsc@ h# 2001 and  ;
 : wait-connect  ( port# -- error? )
    begin                            ( port# )
-      dup portsc@ h# 2001 and  0=   ( port# unconnected? )
+      dup port-connected?  0=       ( port# unconnected? )
    while                            ( port# )
       key?  if                      ( port# )
          key h# 1b =  if            ( port# )   \ ESC aborts
@@ -156,11 +157,11 @@
    ehci-reg dup 0=  if  map-regs  then
 
    #testable-ports  0  ?do
-      i portsc@ h# 2001 and  if		\ Port owned by usb 1.1 controller (2000) or device is present (1)
+      i port-connected?  if		\ Port owned by usb 1.1 controller (2000) or device is present (1)
          ." USB 2.0 port " i u. ."  in use" cr
       else
          diagnostic-mode?  if
-            ." Please connect a device to USB port " i u. " !" cr
+            ." Please connect a device to USB port " i u. cr
             i wait-connect  if  true unloop exit  then
          else
             ." Fisheye pattern out to USB 2.0 port " i u. cr

Modified: dev/usb2/hcd/ehci/qhtd.fth
==============================================================================
--- dev/usb2/hcd/ehci/qhtd.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/hcd/ehci/qhtd.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -549,7 +549,7 @@
 ;
 
 true value delay?
-: poll-delay  ( -- )  d# 100 " us" evaluate  ;
+: poll-delay  ( -- )  d# 300 " us" evaluate  ;
 : done?  ( qh -- usberr )
    delay?  if  poll-delay  then
    begin  dup qh-done?  0=  while   ( qh )

Modified: dev/usb2/hcd/hcd-call.fth
==============================================================================
--- dev/usb2/hcd/hcd-call.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/hcd/hcd-call.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -13,12 +13,15 @@
 \ Probing support
 : set-target  ( device -- )
    " set-target" $call-parent
- ;
+;
 : probe-hub-xt  ( -- adr )
-    " probe-hub-xt" $call-parent
+   " probe-hub-xt" $call-parent
 ;
 : reprobe-hub-xt  ( -- adr )
-    " reprobe-hub-xt" $call-parent
+   " reprobe-hub-xt" $call-parent
+;
+: hub-selftest-xt  ( -- adr )
+   " hub-selftest-xt" $call-parent
 ;
 : set-pipe-maxpayload  ( size len -- )
    " set-pipe-maxpayload" $call-parent

Modified: dev/usb2/hcd/probehub.fth
==============================================================================
--- dev/usb2/hcd/probehub.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/hcd/probehub.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -11,6 +11,9 @@
 
 : power-hub-port   ( port -- )  PORT_POWER  DR_PORT " set-feature" $call-parent drop  ;
 : reset-hub-port   ( port -- )  PORT_RESET  DR_PORT " set-feature" $call-parent drop  d# 20 ms  ;
+\ Test modes: 1:J 2:K 3:SE0_NAK 4:Packet 5:ForceEnable
+: test-hub-port    ( port test-mode -- )  wljoin  PORT_TEST   DR_PORT " set-feature" $call-parent drop  ;
+: untest-hub-port  ( port -- )  PORT_TEST   DR_PORT " clear-feature" $call-parent drop  ;
 : clear-status-change  ( port -- )  C_PORT_CONNECTION  DR_PORT " clear-feature" $call-parent drop  ;
 : parent-set-target  ( dev -- )  " set-target" $call-parent  ;
 : hub-error?  ( -- error? )
@@ -155,6 +158,77 @@
 
 : reprobe-hub-xt  ( -- adr )  ['] do-reprobe-hub  ;
 
+: hub-port-connected?  ( port# -- flag )
+   get-port-status  if  false exit  then
+   hub-buf c@ 1 and  0<>
+;
+0 value hub-dev
+: wait-hub-connect  ( port# -- error? )
+   begin                            ( port# )
+      dup hub-port-connected?  0=   ( port# unconnected? )
+   while                            ( port# )
+      key?  if                      ( port# )
+         key h# 1b =  if            ( port# )   \ ESC aborts
+            drop true exit          ( -- true )
+         then                       ( port# )
+      then                          ( port# )
+   repeat                           ( port# )
+   ." Device connected - probing ... "
+   probe-setup                      ( port# )
+   hub-dev swap ['] probe-hub-port  catch  if  ( x x  )
+      2drop                         ( )
+      ." Failed" cr                 ( )
+      true                          ( true )
+   else                             ( )
+      ." Done" cr                   ( )
+      false                         ( false )
+   then                             ( error? )
+   probe-teardown                   ( error? )
+;
+
+0 value hub-test-mask
+: hub-selftest  ( hub-dev -- error? )
+   to hub-dev                               ( )
+
+   " hub-port-mask" get-inherited-property  if	( )
+      -1					( mask )
+   else						( propval$ )
+      get-encoded-int				( mask )
+   then						( mask )
+   to hub-test-mask				( )
+
+   hub-#ports 1+  1  ?do			( )
+      1  i 1-  lshift  hub-test-mask  and  if
+         hub-dev parent-set-target		( )
+         i get-port-status  if			( )
+            ." Get-port-status failed for hub port " i u. cr
+   	 true unloop exit			( -- true )
+         then					( )
+         hub-buf c@ 8 and  if	\ Connected	( )
+            ." Hub port " i u. ." in over current" cr
+            true unloop exit			( -- true )
+         then					( )
+         hub-buf c@ 1 and  if	\ Connected	( )
+            ." Hub port " i u. ." in use" cr	( )
+         else					( )
+            diagnostic-mode?  if		( )
+               ." Please connect a device to USB hub port " i u.  cr	( )
+               i wait-hub-connect  if  true unloop exit  then			( )
+            else							( )
+               ." Fisheye pattern out to USB hub port " i u. cr		( )
+               i 4 test-hub-port					( )
+               d# 2,000 ms						( )
+               i untest-hub-port					( )
+               i reset-hub-port  i power-hub-port			( )
+            then							( )
+         then								( )
+      then								( )
+   loop									( )
+   \ Mabye need to reset the entire hub here
+   false								( false )
+;
+: hub-selftest-xt  ( -- xt )  ['] hub-selftest  ;
+
 headers
 
 \ LICENSE_BEGIN

Modified: dev/usb2/pkt-data.fth
==============================================================================
--- dev/usb2/pkt-data.fth	Thu May 26 23:23:22 2011	(r2232)
+++ dev/usb2/pkt-data.fth	Fri May 27 04:16:25 2011	(r2233)
@@ -72,11 +72,13 @@
 04 constant PORT_RESET
 08 constant PORT_POWER
 09 constant PORT_LOW_SPEED
-10 constant C_PORT_CONNECTION
-11 constant C_PORT_ENABLE
-12 constant C_PORT_SUSPEND
-13 constant C_PORT_OVER_CURRENT
-14 constant C_PORT_RESET
+d# 16 constant C_PORT_CONNECTION
+d# 17 constant C_PORT_ENABLE
+d# 18 constant C_PORT_SUSPEND
+d# 19 constant C_PORT_OVER_CURRENT
+d# 20 constant C_PORT_RESET
+d# 21 constant PORT_TEST
+d# 22 constant PORT_INDICATOR
 
 \ Use tmp-l to make sure that le-l! and le-w! are atomic writes
 



More information about the openfirmware mailing list