Changeset 3011


Ignore:
Timestamp:
Jun 16, 2012, 4:13:21 AM (3 years ago)
Author:
quozl
Message:

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

Location:
dev/usb2/hcd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dev/usb2/hcd/device.fth

    r2745 r3011  
    392392\ Executed in root hub node context
    393393: get-str-descriptors  ( -- )
    394    language                                     ( lang )
    395    dup dev-desc-buf d# 14 + c@ v$-desc-buf get-string to /v$-desc-buf
    396    dup dev-desc-buf d# 15 + c@ d$-desc-buf get-string to /d$-desc-buf
    397        dev-desc-buf d# 16 + c@ s$-desc-buf get-string to /s$-desc-buf
     394   language                                     ( lang )
     395   dup d# 14 dev-desc@ v$-desc-buf get-string to /v$-desc-buf
     396   dup d# 15 dev-desc@ d$-desc-buf get-string to /d$-desc-buf
     397       d# 16 dev-desc@ s$-desc-buf get-string to /s$-desc-buf
    398398;
    399399
     
    401401: refresh-desc-bufs  ( dev -- )
    402402   set-target
    403    dev-desc-buf 12 get-dev-desc to /dev-desc-buf                \ Refresh dev-desc-buf
    404    cfg-desc-buf  0 get-cfg-desc to /cfg-desc-buf                \ Refresh cfg-desc-buf
     403   dev-desc-buf d# 18 get-dev-desc to /dev-desc-buf             \ Refresh dev-desc-buf
     404   cfg-desc-buf     0 get-cfg-desc to /cfg-desc-buf             \ Refresh cfg-desc-buf
    405405   get-str-descriptors
    406406;
    407407
    408408\ Executed in root hub node context
    409 : get-initial-descriptors  ( dev -- )
    410    dev-desc-buf /pipe0 get-dev-desc  if         ( dev )
    411       dev-desc-buf 7 + c@ 0 rot di-maxpayload!  ( )
    412    else                                         ( dev )
    413       drop                                      ( )
    414    then                                         ( )
    415    cfg-desc-buf 0 get-cfg-desc to /cfg-desc-buf ( )
     409: get-initial-descriptors  ( -- )
     410   \ Re-read the full device descriptor to pick up the vendor info
     411   dev-desc-buf d# 18 get-dev-desc  drop                ( )
     412   cfg-desc-buf     0 get-cfg-desc to /cfg-desc-buf     ( )
    416413;
    417414
    418415\ Executed in hub node context (root hub or subordinate hub) - creates new child nodes via (make-device-node)
    419416: make-device-node  ( port dev -- )
    420    dup " get-initial-descriptors" my-self $call-method  ( port dev )
     417   " get-initial-descriptors" my-self $call-method      ( port dev )
    421418   /cfg-desc-buf 0=  if  2drop  exit  then              ( port dev )
    422419   asso-class?  if  1  else  cfg-desc-buf 4 + c@  then  ( port dev #intf )
     
    444441;
    445442
     443: get-initial-dev-desc  ( dev -- )
     444   dev-desc-buf d# 18 erase                     ( dev )
     445   dev-desc-buf d# 64 get-dev-desc  0=  if      ( dev )
     446      dev-desc-buf /pipe0 get-dev-desc  0=  if  ( dev )
     447         drop exit
     448      then
     449   then
     450   7 dev-desc@ 0 rot di-maxpayload!             ( )
     451;
     452
    446453\ Executed in the root hub node context
    447454: setup-new-node  ( port speed hub-port hub-dev -- true | port dev xt false )
     
    454461
    455462   0 set-target                         ( port dev )    \ Address it as device 0
    456    over reset-port                      ( port dev )    \ Some devices want to be reset here
     463
     464   \ Some devices (e.g. Lexar USB-to-SD and at least one USB FLASH drive) fail
     465   \ on set-address unless you first read the device descriptor from address 0.
     466   dup get-initial-dev-desc             ( port dev )
     467
    457468   dup set-address  if                  ( port dev )    \ Assign it usb addr dev
    458469      ." Retrying with a delay" cr
  • dev/usb2/hcd/ehci/probe.fth

    r3004 r3011  
    88
    99: make-root-hub-node  ( port -- )
    10    \ Some devices (e.g. Lexar USB-to-SD) fail unless you get the cfg desc from device 0 first
    1110   0 set-target \ First address it as device 0  ( port )
    1211   port-speed 0 di-speed!     \ Use high speed for getting the device descriptor
    13    dev-desc-buf h# 40 get-cfg-desc drop         ( port )
    14 
     12   dup reset-port                               ( port )
    1513   port-speed                                   ( port speed )
    1614
     
    1917
    2018   \ Execute setup-new-node in root context and make-device-node in hub node context
    21    setup-new-node  if  execute  then    ( )
     19   setup-new-node  if  execute  then            ( )
    2220;
    2321
Note: See TracChangeset for help on using the changeset viewer.