Author: wmb Date: Thu Dec 8 13:43:07 2011 New Revision: 2746 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2746
Log: USB EHCI driver - support low and full speed devices connected to EHCI controller, as some EHCI controllers can handle them without needing a companion controller.
Modified: cpu/arm/olpc/3.0/usb.fth dev/usb2/hcd/ehci/probe.fth
Modified: cpu/arm/olpc/3.0/usb.fth ============================================================================== --- cpu/arm/olpc/3.0/usb.fth Thu Dec 8 13:43:02 2011 (r2745) +++ cpu/arm/olpc/3.0/usb.fth Thu Dec 8 13:43:07 2011 (r2746) @@ -16,6 +16,11 @@ : otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode ' otg-set-host-mode to set-host-mode
+ \ The Marvell EHCI can handle low and full speed devices directly, + \ without needing a UHCI or OHCI companion controller + ' make-port-node to handle-ls-device + ' make-port-node to handle-fs-device + : sleep ( -- ) true to first-open? ; : wake ( -- ) ; end-package @@ -33,11 +38,17 @@ fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth \ false to delay? \ No need for a polling delay on this platform
+ \ The Marvell EHCI can handle low and full speed devices directly, + \ without needing a UHCI or OHCI companion controller + ' make-port-node to handle-ls-device + ' make-port-node to handle-fs-device + : sleep ( -- ) true to first-open? ; : wake ( -- ) ; end-package
-\ Turn on USB power after a delay, to ensure that USB devices are reset correctly on boot +\ usb-power-on is unnecessary on initial boot, as CForth turns on the +\ USB power during its GPIO setup. : usb-power-on ( -- ) d# 126 gpio-clr \ OTG 5V on d# 127 gpio-clr \ ULPI 5V on @@ -56,7 +67,7 @@ ;
stand-init: Init USB Phy -\ usb-power-on \ The EC now controls the USB power +\ usb-power-on \ The USB power is turned on early, when CForth sets up GPIOs init-usb ;
@@ -118,17 +129,24 @@ alias p2 probe-usb
0 value usb-keyboard-ih +0 value otg-keyboard-ih
: attach-usb-keyboard ( -- ) " usb-keyboard" expand-alias if ( devspec$ ) drop " /usb" comp 0= if ( ) " usb-keyboard" open-dev to usb-keyboard-ih usb-keyboard-ih add-input - exit then else ( devspec$ ) 2drop then + + " otg/keyboard" expand-alias if ( devspec$ ) + open-dev to otg-keyboard-ih + otg-keyboard-ih add-input + else + 2drop + then ;
: detach-usb-keyboard ( -- )
Modified: dev/usb2/hcd/ehci/probe.fth ============================================================================== --- dev/usb2/hcd/ehci/probe.fth Thu Dec 8 13:43:02 2011 (r2745) +++ dev/usb2/hcd/ehci/probe.fth Thu Dec 8 13:43:07 2011 (r2746) @@ -4,13 +4,15 @@ hex headers
+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 ) - speed-high 0 di-speed! \ Use high speed for getting the device descriptor + port-speed 0 di-speed! \ Use high speed for getting the device descriptor dev-desc-buf h# 40 get-cfg-desc drop ( port )
- speed-high ( port speed ) + 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 ) @@ -21,22 +23,31 @@
0 instance value probe-error? \ Back channel to selftest
+: make-port-node ( port -- ) + ['] make-root-hub-node catch if + drop ." Failed to make root hub node for port " dup .d cr + true to probe-error? + then +; +defer handle-ls-device ' disown-port to handle-ls-device +defer handle-fs-device ' disown-port to handle-fs-device + : probe-root-hub-port ( port -- ) false to probe-error? ( port ) dup disable-old-nodes ( port ) dup portsc@ 1 and 0= if drop exit then ( port ) \ No device detected
dup portsc@ h# c00 and h# 400 = if \ A low speed device detected - dup disown-port \ Disown the port + speed-low to port-speed + dup handle-ls-device \ Process low-speed device else \ Don't know what it is dup reset-port \ Reset to find out dup portsc@ 4 and 0= if \ A full speed device detected - dup disown-port \ Disown the port + speed-full to port-speed + dup handle-fs-device \ Process full-speed device else \ A high speed device detected - dup ['] make-root-hub-node catch if \ Process high speed device - drop ." Failed to make root hub node for port " dup .d cr - true to probe-error? - then + speed-high to port-speed + dup make-port-node \ Process high-speed device then then ( port# ) dup portsc@ swap portsc! ( ) \ Clear connection change bit