Author: quozl Date: Sat Jun 16 04:13:21 2012 New Revision: 3011 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3011
Log: OLPC - dev/usb2, read the device descriptor after reset and before set-address, instead of after set-address. Erase the device descriptor buffer before reading. #11931
Modified: dev/usb2/hcd/device.fth dev/usb2/hcd/ehci/probe.fth
Modified: dev/usb2/hcd/device.fth ============================================================================== --- dev/usb2/hcd/device.fth Fri Jun 15 03:58:55 2012 (r3010) +++ dev/usb2/hcd/device.fth Sat Jun 16 04:13:21 2012 (r3011) @@ -391,33 +391,30 @@
\ Executed in root hub node context : get-str-descriptors ( -- ) - language ( lang ) - dup dev-desc-buf d# 14 + c@ v$-desc-buf get-string to /v$-desc-buf - dup dev-desc-buf d# 15 + c@ d$-desc-buf get-string to /d$-desc-buf - dev-desc-buf d# 16 + c@ s$-desc-buf get-string to /s$-desc-buf + language ( lang ) + dup d# 14 dev-desc@ v$-desc-buf get-string to /v$-desc-buf + dup d# 15 dev-desc@ d$-desc-buf get-string to /d$-desc-buf + d# 16 dev-desc@ s$-desc-buf get-string to /s$-desc-buf ;
\ Executed in root hub node context : refresh-desc-bufs ( dev -- ) set-target - dev-desc-buf 12 get-dev-desc to /dev-desc-buf \ Refresh dev-desc-buf - cfg-desc-buf 0 get-cfg-desc to /cfg-desc-buf \ Refresh cfg-desc-buf + dev-desc-buf d# 18 get-dev-desc to /dev-desc-buf \ Refresh dev-desc-buf + cfg-desc-buf 0 get-cfg-desc to /cfg-desc-buf \ Refresh cfg-desc-buf get-str-descriptors ;
\ Executed in root hub node context -: get-initial-descriptors ( dev -- ) - dev-desc-buf /pipe0 get-dev-desc if ( dev ) - dev-desc-buf 7 + c@ 0 rot di-maxpayload! ( ) - else ( dev ) - drop ( ) - then ( ) - cfg-desc-buf 0 get-cfg-desc to /cfg-desc-buf ( ) +: get-initial-descriptors ( -- ) + \ Re-read the full device descriptor to pick up the vendor info + dev-desc-buf d# 18 get-dev-desc drop ( ) + cfg-desc-buf 0 get-cfg-desc to /cfg-desc-buf ( ) ;
\ Executed in hub node context (root hub or subordinate hub) - creates new child nodes via (make-device-node) : make-device-node ( port dev -- ) - dup " get-initial-descriptors" my-self $call-method ( port dev ) + " get-initial-descriptors" my-self $call-method ( port dev ) /cfg-desc-buf 0= if 2drop exit then ( port dev ) asso-class? if 1 else cfg-desc-buf 4 + c@ then ( port dev #intf ) 0 ?do ( port dev ) @@ -443,6 +440,16 @@ then ( port ) ;
+: get-initial-dev-desc ( dev -- ) + dev-desc-buf d# 18 erase ( dev ) + dev-desc-buf d# 64 get-dev-desc 0= if ( dev ) + dev-desc-buf /pipe0 get-dev-desc 0= if ( dev ) + drop exit + then + then + 7 dev-desc@ 0 rot di-maxpayload! ( ) +; + \ Executed in the root hub node context : setup-new-node ( port speed hub-port hub-dev -- true | port dev xt false ) \ Allocate device number @@ -453,7 +460,11 @@ tuck di-speed! ( port dev )
0 set-target ( port dev ) \ Address it as device 0 - over reset-port ( port dev ) \ Some devices want to be reset here + + \ Some devices (e.g. Lexar USB-to-SD and at least one USB FLASH drive) fail + \ on set-address unless you first read the device descriptor from address 0. + dup get-initial-dev-desc ( port dev ) + dup set-address if ( port dev ) \ Assign it usb addr dev ." Retrying with a delay" cr over reset-port d# 5000 ms
Modified: dev/usb2/hcd/ehci/probe.fth ============================================================================== --- dev/usb2/hcd/ehci/probe.fth Fri Jun 15 03:58:55 2012 (r3010) +++ dev/usb2/hcd/ehci/probe.fth Sat Jun 16 04:13:21 2012 (r3011) @@ -7,18 +7,16 @@ 0 value port-speed
: make-root-hub-node ( port -- ) - \ Some devices (e.g. Lexar USB-to-SD) fail unless you get the cfg desc from device 0 first 0 set-target \ First address it as device 0 ( port ) port-speed 0 di-speed! \ Use high speed for getting the device descriptor - dev-desc-buf h# 40 get-cfg-desc drop ( port ) - + dup reset-port ( port ) port-speed ( port speed )
\ hub-port and hub-dev route USB 1.1 transactions through USB 2.0 hubs over get-hub20-port get-hub20-dev ( port speed hub-port hub-dev )
\ Execute setup-new-node in root context and make-device-node in hub node context - setup-new-node if execute then ( ) + setup-new-node if execute then ( ) ;
0 instance value probe-error? \ Back channel to selftest