Author: wmb Date: Tue Nov 20 23:27:07 2012 New Revision: 3444 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3444
Log: USB - Changed selftest logic so that it will not destroy (by wanton reprobing) the setup of devices that were connected prior to the execution of selftest. This fixes OLPC trac #12254 and corrects the fix to OLPC trac #11845. I also made it possible to invoke the fisheye test by supplying the argument "fisheye" to the usb path, as in "test /usb:fisheye" or "test /usb:fisheye/hub" . The fisheye test is only available when diag-switch? is false.
Modified: dev/usb2/hcd/device.fth dev/usb2/hcd/ehci/probe.fth dev/usb2/hcd/hcd.fth dev/usb2/hcd/probehub.fth
Modified: dev/usb2/hcd/device.fth ============================================================================== --- dev/usb2/hcd/device.fth Tue Nov 20 02:49:48 2012 (r3443) +++ dev/usb2/hcd/device.fth Tue Nov 20 23:27:07 2012 (r3444) @@ -357,6 +357,46 @@ drop ( ) ;
+: find-port-node ( port -- true | phandle false) + my-self ihandle>phandle child ( port phandle ) + begin ?dup while ( port phandle ) + " reg" 2 pick get-package-property 0= if ( port phandle adr len ) + decode-int nip nip ( port phandle port1 ) + 2 pick = if ( port phandle ) + \ Check if the node has been disabled + " assigned-address" ( port phandle propname$ ) + 2 pick get-package-property 0= if ( port phandle adr len ) + decode-int nip nip ( port phandle assigned-address ) + -1 <> if ( port phandle ) + nip false exit + then + then ( port phandle ) + then ( port phandle ) + then ( port phandle ) + peer ( port phandle' ) + repeat ( port ) + drop ( ) + true +; + +: .phandle-property ( phandle prop-name$ -- ) + rot get-package-property 0= if ( adr len ) + decode-string type 2drop + then +; +: .usb-device ( port -- ) + find-port-node if + ." Can't find device node for USB port!" cr + else ( phandle ) + dup " device_type" .phandle-property ( phandle ) + ." ," + dup " vendor$" .phandle-property ( phandle ) + ." ," + dup " device$" .phandle-property ( phandle ) + drop ( ) + then +; + : (make-device-node) ( dev port intf -- ) swap ( dev intf port ) 3dup reuse-old-node? if ( dev intf port )
Modified: dev/usb2/hcd/ehci/probe.fth ============================================================================== --- dev/usb2/hcd/ehci/probe.fth Tue Nov 20 02:49:48 2012 (r3443) +++ dev/usb2/hcd/ehci/probe.fth Tue Nov 20 23:27:07 2012 (r3444) @@ -84,9 +84,10 @@
: power-usb-ports ( -- ) ;
+: port-changed? ( port# -- flag ) portsc@ 2 and 0<> ; : ports-changed? ( -- flag ) #ports 0 ?do - i portsc@ 2 and if true unloop exit then + i port-changed? if true unloop exit then loop false ; @@ -95,7 +96,7 @@ probe-setup
#ports 0 ?do \ For each port - i portsc@ 2 and if \ Connection changed + i port-changed? if \ Connection changed \ i rm-obsolete-children \ Remove obsolete device nodes i probe-root-hub-port \ Probe it else @@ -154,58 +155,36 @@ open-count 0= if free-dma-buf unmap-regs then ;
-: .occupied ( port -- ) ." USB 2.0 port " u. ." in use" cr ; : regs{ ( -- prev ) ehci-reg dup 0= if map-regs then ; : }regs ( prev -- ) 0= if unmap-regs then ;
-: fisheye ( -- ) - regs{ - #testable-ports 0 ?do - i port-connected? if - i .occupied - else - ." Fisheye pattern out to USB 2.0 port " i u. cr - i test-port-begin - d# 2,000 ms - i test-port-end - 0 i portsc! i reset-port i power-port - then - loop - }regs -; - -: thorough ( -- error? ) - #testable-ports 0 ?do - i port-connected? if - i .occupied - else - ." Please connect a device to USB port " i u. cr - i wait-connect if true unloop exit then - then - loop - false -; - -: sagacity ( -- error? ) +: selftest ( -- error? ) + open 0= if true exit then #testable-ports 0 ?do - ." USB port " i u. ." ... " + ." USB port " i u. ." : " i port-connected? if - i wait-connect if true unloop exit then + ." In use - " + i .usb-device cr else - ." Empty" cr + diagnostic-mode? if + ." Please connect a device" cr + i wait-connect if true unloop exit then + i .usb-device cr + else + fisheye? if + ." Fisheye pattern" cr + i test-port-begin + d# 2,000 ms + i test-port-end + 0 i portsc! i reset-port i power-port + else + ." Empty" cr + then + then then loop false -; - -: selftest ( -- error? ) - regs{ ( prev ) - diagnostic-mode? if - thorough - else - sagacity - then ( prev error? ) - swap }regs ( error? ) + close ;
headers
Modified: dev/usb2/hcd/hcd.fth ============================================================================== --- dev/usb2/hcd/hcd.fth Tue Nov 20 02:49:48 2012 (r3443) +++ dev/usb2/hcd/hcd.fth Tue Nov 20 23:27:07 2012 (r3444) @@ -116,12 +116,15 @@ \ " rm-usb-children" $find if execute else 3drop then \ ;
+false instance value fisheye? + : parse-my-args ( -- ) my-args begin dup while ascii , left-parse-string ( rem$' opt$ ) 2dup " debug" $= if debug-on then 2dup " noprobe" $= if true to noprobe? then + 2dup " fisheye" $= if true to fisheye? then 2drop ( rem$ ) repeat ( rem$ ) 2drop ( )
Modified: dev/usb2/hcd/probehub.fth ============================================================================== --- dev/usb2/hcd/probehub.fth Tue Nov 20 02:49:48 2012 (r3443) +++ dev/usb2/hcd/probehub.fth Tue Nov 20 23:27:07 2012 (r3444) @@ -195,24 +195,31 @@ ." Get-port-status failed for hub port " r@ u. cr r> drop true exit ( -- true ) then ( ) + ." Hub port " r@ u. ." : " ( ) hub-buf c@ 8 and if \ Connected ( ) - ." Hub port " r@ u. ." in over current" cr + ." In over current" cr ( ) r> drop true exit ( -- true ) then ( ) hub-buf c@ 1 and if \ Connected ( ) - ." Hub port " r@ u. ." in use" cr ( ) + ." In use - " ( ) + r@ .usb-device cr ( ) else ( ) diagnostic-mode? if ( ) - ." Please connect a device to USB hub port " r@ u. cr ( ) - r@ wait-hub-connect if r> drop true exit then ( ) - else ( ) - ." Fisheye pattern out to USB hub port " r@ u. cr ( ) - r@ 4 test-hub-port ( ) - d# 2,000 ms ( ) - r@ untest-hub-port ( ) - r@ reset-hub-port r@ power-hub-port ( ) - then ( ) - then ( ) + ." Please connect a device" cr ( ) + r@ wait-hub-connect if r> drop true exit then ( ) + r@ .usb-device cr ( ) + else ( ) + " fisheye?" $call-parent if ( ) + ." Fisheye pattern" cr ( ) + r@ 4 test-hub-port ( ) + d# 2,000 ms ( ) + r@ untest-hub-port ( ) + r@ reset-hub-port r@ power-hub-port ( ) + else ( ) + ." Empty" cr ( ) + then ( ) + then ( ) + then ( ) r> drop false ;
openfirmware@openfirmware.info