Author: quozl
Date: Thu Dec 9 06:30:02 2010
New Revision: 2076
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2076
Log:
SDHCI - restore previous delay for internal slot, adopt 250ms delay following tests with external slot. May be revisited with XO-1.75 A2 where only 1ms may be required.
Modified:
dev/mmc/sdhci/sdhci.fth
Modified: dev/mmc/sdhci/sdhci.fth
==============================================================================
--- dev/mmc/sdhci/sdhci.fth Wed Dec 8 23:17:20 2010 (r2075)
+++ dev/mmc/sdhci/sdhci.fth Thu Dec 9 06:30:02 2010 (r2076)
@@ -384,7 +384,7 @@
: response ( -- l ) h# 10 cl@ ;
-: buf+! ( buf value -- buf' ) over l! la1+ ;
+\ : buf+! ( buf value -- buf' ) over l! la1+ ;
\ Store in the buffer in little-endian form
: get-response136 ( buf -- ) \ 128 bits (16 bytes) of data.
@@ -801,16 +801,19 @@
false to writing?
;
-\ time to hold card power off to allow VCC_SD to discharge
+\ time to hold external card power off to allow VCC_SD to discharge
+\ 250ms required for XO-1.5 to achieve 0.5V
\ 25ms required for XO-1.5 with external SanDisk 32 G class 10 SD card
\ 29ms required for XO-1.5 with external SanDisk 8 G class 4 SD card
\ 1ms should be required for XO-1.75 A2 (due to discharge clamps)
-d# 40 value power-off-time
+d# 250 value power-off-time
\ -1 means error, 1 means retry
: power-up-card ( -- false | retry? true )
intstat-on
- card-power-off power-off-time ms
+ card-power-off
+ slot 1 = if power-off-time else d# 20 then
+ ms
card-power-on d# 40 ms \ This delay is just a guess (20 was barely too slow for a Via board)
card-inserted? 0= if card-power-off intstat-off false true exit then
card-clock-slow d# 10 ms \ This delay is just a guess
Author: wmb
Date: Wed Dec 8 23:17:20 2010
New Revision: 2075
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2075
Log:
OLPC XO-1.75 - reinstated USB polling delay to prevent TIMEOUT messages.
Modified:
cpu/arm/olpc/1.75/usb.fth
Modified: cpu/arm/olpc/1.75/usb.fth
==============================================================================
--- cpu/arm/olpc/1.75/usb.fth Wed Dec 8 22:39:38 2010 (r2074)
+++ cpu/arm/olpc/1.75/usb.fth Wed Dec 8 23:17:20 2010 (r2075)
@@ -12,7 +12,7 @@
false constant needs-dummy-qh?
: grab-controller ( config-adr -- error? ) drop false ;
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
- false to delay? \ No need for a polling delay on this platform
+\ false to delay? \ No need for a polling delay on this platform
: otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode
' otg-set-host-mode to set-host-mode
Author: wmb
Date: Wed Dec 8 22:32:08 2010
New Revision: 2073
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2073
Log:
OLPC XO-1.75 - added automatic USB probing at startup, now that USB is working.
Added:
cpu/arm/olpc/1.75/usb.fth
Modified:
cpu/arm/olpc/1.75/devices.fth
cpu/arm/olpc/1.75/fw.bth
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Wed Dec 8 22:30:16 2010 (r2072)
+++ cpu/arm/olpc/1.75/devices.fth Wed Dec 8 22:32:08 2010 (r2073)
@@ -229,27 +229,52 @@
devalias keyboard /ec-spi/keyboard
-0 0 " d4208000" " /" begin-package \ USB Host Controller
- h# 200 constant /regs
- my-address my-space /regs reg
- : my-map-in ( len -- adr )
- my-space swap " map-in" $call-parent h# 100 + ( adr )
- ;
- : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
- false constant has-dbgp-regs?
- false constant needs-dummy-qh?
- : grab-controller ( config-adr -- error? ) drop false ;
- fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
- : otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode
- ' otg-set-host-mode to set-host-mode
-
-end-package
-
: wlan-reset ( -- ) d# 58 gpio-clr d# 20 ms d# 58 gpio-set ;
-\ : usb-power-on ( -- ) 1 gpio-set ;
-: usb-power-on ( -- ) ; \ The EC controls the USB power
-: reset-usb-hub ( -- ) d# 146 gpio-set d# 10 ms d# 146 gpio-set ;
+\ Create the alias unless it already exists
+: $?devalias ( alias$ value$ -- )
+ 2over not-alias? if $devalias exit then ( alias$ value$ alias$ )
+ 2drop 4drop
+;
+
+: ?report-device ( alias$ pathname$ -- )
+ 2dup locate-device 0= if ( alias$ pathname$ phandle )
+ drop ( alias$ pathname$ )
+ 2over 2over $?devalias ( alias$ pathname$ )
+ then ( alias$ pathname$ )
+ 4drop ( )
+;
+
+: report-disk ( -- )
+ " disk" " /usb/disk" ?report-device
+;
+
+: report-keyboard ( -- )
+ \ Prefer direct-attached
+ " usb-keyboard" " /usb/keyboard" ?report-device \ USB 2 (keyboard behind a hub)
+;
+
+\ If there is a USB ethernet adapter, use it as the default net device.
+\ We can't use ?report-device here because we already have net aliased
+\ to /wlan, and ?report-device won't override an existing alias.
+: report-net ( -- )
+ " /usb/ethernet" 2dup locate-device 0= if ( name$ phandle )
+ drop ( name$ )
+
+ \ Don't recreate the alias if it is already correct
+ " net" aliased? if ( name$ existing-name$ )
+ 2over $= if ( name$ )
+ 2drop exit ( -- )
+ then ( name$ )
+ then ( name$ )
+
+ " net" 2swap $devalias ( )
+ else ( name$ )
+ 2drop ( )
+ then
+;
+
+fload ${BP}/cpu/arm/olpc/1.75/usb.fth
fload ${BP}/cpu/arm/marvell/utmiphy.fth
Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth Wed Dec 8 22:30:16 2010 (r2072)
+++ cpu/arm/olpc/1.75/fw.bth Wed Dec 8 22:32:08 2010 (r2073)
@@ -23,6 +23,14 @@
[then]
fload ${BP}/cpu/arm/linux.fth
+
+: usb-quiet ( -- )
+ [ ' linux-hook behavior compile, ] \ Chain to old behavior
+ " /usb" " reset-usb" execute-device-method drop
+;
+
+' usb-quiet to linux-hook
+
d# 9999 to arm-linux-machine-type \ Marvell Jasper
\ Add a tag describing the linear frame buffer
@@ -360,9 +368,9 @@
factory-test? 0= if secure-startup then
unblock-exceptions
['] (interrupt-auto-boot?) to interrupt-auto-boot?
-[ifdef] notyet
+
?usb-keyboard
-[then]
+
auto-banner? if banner then
auto-boot
Added: cpu/arm/olpc/1.75/usb.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/usb.fth Wed Dec 8 22:32:08 2010 (r2073)
@@ -0,0 +1,141 @@
+purpose: USB elaborations for the BIOS loaded OFW
+\ See license at end of file
+
+0 0 " d4208000" " /" begin-package \ USB Host Controller
+ h# 200 constant /regs
+ my-address my-space /regs reg
+ : my-map-in ( len -- adr )
+ my-space swap " map-in" $call-parent h# 100 + ( adr )
+ ;
+ : my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
+ false constant has-dbgp-regs?
+ false constant needs-dummy-qh?
+ : grab-controller ( config-adr -- error? ) drop false ;
+ fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
+ false to delay? \ No need for a polling delay on this platform
+ : otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode
+ ' otg-set-host-mode to set-host-mode
+
+end-package
+
+d# 300 config-int usb-delay \ Milliseconds to wait before probing hub ports
+
+devalias u /usb/disk
+
+\ Like $show-devs, but ignores pagination keystrokes
+: $nopage-show-devs ( nodename$ -- )
+ ['] exit? behavior >r ['] false to exit?
+ $show-devs
+ r> to exit?
+;
+
+\ Restrict selftest to external USB ports 1,2,3
+\ dev / 3 " usb-test-ports" integer-property dend
+
+: (probe-usb2) ( -- )
+ " device_type" get-property if exit then
+[ifdef] use-usb-debug-port
+ \ I haven't figured out how to turn on the EHCI cleanly
+ \ when the Debug Port is running
+ dbgp-off
+[then]
+ get-encoded-string " ehci" $= if
+ pwd$ open-dev ?dup if close-dev then
+ then
+;
+: (show-usb2) ( -- )
+ " device_type" get-property if exit then
+ get-encoded-string " ehci" $= if
+ pwd$ $nopage-show-devs
+ then
+;
+
+: silent-probe-usb ( -- )
+ " /" ['] (probe-usb2) scan-subtree
+ report-disk report-net report-keyboard
+;
+: probe-usb ( -- )
+ silent-probe-usb
+
+ ." USB devices:" cr
+ " /" ['] (show-usb2) scan-subtree
+
+;
+alias p2 probe-usb
+
+0 value usb-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
+;
+
+: detach-usb-keyboard ( -- )
+ usb-keyboard-ih if
+ usb-keyboard-ih remove-input
+ usb-keyboard-ih close-dev
+ 0 to usb-keyboard-ih
+ then
+;
+
+: ?usb-keyboard ( -- )
+ attach-usb-keyboard
+ " /usb/serial" open-dev ?dup if
+ add-input
+ then
+;
+
+\ Unlink every node whose phys.hi component matches port
+: port-match? ( port -- flag )
+ get-unit if drop false exit then
+ get-encoded-int =
+;
+: rm-usb-children ( port -- )
+ device-context? 0= if drop exit then
+ also ( port )
+ 'child ( port prev )
+ first-child begin while ( port prev )
+ over port-match? if ( port prev )
+ 'peer link@ over link! ( port prev ) \ Disconnect
+ else ( port prev )
+ drop 'peer ( port prev' )
+ then ( port prev )
+ next-child repeat ( port prev )
+ 2drop ( )
+ previous definitions
+;
+
+\ Turn on USB power after a delay, to ensure that USB devices are reset correctly on boot
+: usb-power-on ( -- ) ; \ The EC controls the USB power
+: reset-usb-hub ( -- ) d# 146 gpio-set d# 10 ms d# 146 gpio-set ;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Author: wmb
Date: Wed Dec 8 22:28:37 2010
New Revision: 2071
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2071
Log:
biosints.fth - added commentary explaining some complicated stuff.
Modified:
cpu/x86/pc/biosints.fth
Modified: cpu/x86/pc/biosints.fth
==============================================================================
--- cpu/x86/pc/biosints.fth Wed Dec 8 22:27:30 2010 (r2070)
+++ cpu/x86/pc/biosints.fth Wed Dec 8 22:28:37 2010 (r2071)
@@ -1067,8 +1067,11 @@
16-bit
ax push
h# 20 # ax mov
- al h# 20 # out
+ al h# 20 # out \ Writing h# 20 to IO port 20 is interrupt ack
ax pop
+ \ After acking the hardware interrupt, we call the INT 1c vector,
+ \ which NTLDR hooks when it wants to receive timer ticks. That
+ \ vector will perform the IRET to return from the hardware interrupt.
cs: h# 72 #) push
cs: h# 70 #) push
far ret
@@ -1081,6 +1084,9 @@
bounce-timer h# c0 /bounce-timer move
\ Change INT 20 (the timer tick) to point to the bounce vector with CS=0
+ \ INT 20 is called by the timer hardware via IRQ 0, which vectors to INT 20
+ \ (vector-base0 = 0x20). The following causes it to execute the "bounce-timer"
+ \ code which has been placed at location 0xc0.
0 h# 82 w! h# c0 h# 80 w! \ CS = 0, IP = h# c0 = INT 30
;