Author: wmb
Date: Thu May 26 02:16:32 2011
New Revision: 2227
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2227
Log:
OLPC trac #10889 and #10890 - Added LEDs and switches selftests to XO-1.75.
Added:
cpu/arm/olpc/1.75/leds.fth
cpu/arm/olpc/1.75/switches.fth
Modified:
cpu/arm/olpc/1.75/fw.bth
Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth Thu May 26 01:56:39 2011 (r2226)
+++ cpu/arm/olpc/1.75/fw.bth Thu May 26 02:16:32 2011 (r2227)
@@ -146,6 +146,10 @@
fload ${BP}/cpu/x86/pc/olpc/plot.fth
fload ${BP}/cpu/arm/olpc/1.75/testinstructions.fth
+fload ${BP}/cpu/arm/olpc/1.75/switches.fth \ Lid and ebook switches
+fload ${BP}/cpu/arm/olpc/1.75/leds.fth \ LEDs
+\ fload ${BP}/cpu/x86/pc/olpc/via/factory.fth \ Manufacturing tools
+
\ Pseudo device that appears in the boot order before net booting
0 0 " " " /" begin-package
" prober" device-name
Added: cpu/arm/olpc/1.75/leds.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/leds.fth Thu May 26 02:16:32 2011 (r2227)
@@ -0,0 +1,42 @@
+\ See license at end of file
+purpose: Driver/selftest for OLPC XO-1.75 LEDs
+
+0 0 " 0" " /" begin-package
+0 0 reg \ So test-all will run the test
+" leds" device-name
+: open ( -- okay? ) true ;
+: close ( -- ) ;
+: hdd-led-on ( -- ) d# 10 gpio-set ;
+: hdd-led-off ( -- ) d# 10 gpio-clr ;
+: selftest ( -- )
+ ." Flashing LEDs" cr
+ " /wlan" test-dev " /wlan" test-dev \ Twice for longer flashing
+ d# 20 0 do hdd-led-on d# 100 ms hdd-led-off d# 100 ms loop
+ confirm-selftest?
+;
+
+end-package
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/arm/olpc/1.75/switches.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/switches.fth Thu May 26 02:16:32 2011 (r2227)
@@ -0,0 +1,63 @@
+\ See license at end of file
+purpose: Driver/selftest for OLPC lid and ebook switches
+
+0 0 " 0" " /" begin-package
+" switches" device-name
+0 0 reg \ So test-all will run the test
+: open ( -- okay? ) true ;
+: close ( -- ) ;
+: lid? ( -- flag ) d# 129 gpio-pin@ 0= ;
+: ebook? ( -- flag ) d# 128 gpio-pin@ 0= ;
+
+: ?key-abort ( -- ) key? if key esc = abort" Aborted" then ;
+: wait-not-lid ( -- )
+ ." Deactivate lid switch" cr
+ begin ?key-abort lid? 0= until
+;
+: wait-lid ( -- )
+ ." Activate lid switch" cr
+ begin ?key-abort lid? until
+;
+: wait-not-ebook ( -- )
+ ." Deactivate ebook switch" cr
+ begin ?key-abort ebook? 0= until
+;
+: wait-ebook ( -- )
+ ." Activate ebook switch" cr
+ begin ?key-abort ebook? until
+;
+
+: all-switch-states ( -- )
+ lid? if wait-not-lid else wait-lid then
+ ebook? if wait-not-ebook else wait-ebook then
+;
+
+: selftest ( -- error? )
+ ['] all-switch-states catch
+;
+
+end-package
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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: Thu May 26 01:13:22 2011
New Revision: 2225
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2225
Log:
OLPC trac #10888 - Handle XO-1.75 game buttons in keyboard selftest.
Modified:
cpu/arm/olpc/1.75/fw.bth
dev/olpc/keyboard/selftest.fth
Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth Wed May 25 23:41:47 2011 (r2224)
+++ cpu/arm/olpc/1.75/fw.bth Thu May 26 01:13:22 2011 (r2225)
@@ -156,19 +156,6 @@
: close ;
end-package
-fload ${BP}/dev/logdev.fth
-0 value smt-test? \ !!!
-0 value final-test? \ !!!
-fload ${BP}/cpu/x86/pc/olpc/disptest.fth
-fload ${BP}/dev/olpc/keyboard/selftest.fth \ Keyboard diagnostic
-fload ${BP}/dev/olpc/touchpad/syntpad.fth \ Touchpad diagnostic
-fload ${BP}/cpu/x86/pc/olpc/gridmap.fth \ Gridded display tools
-fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
-fload ${BP}/cpu/arm/olpc/1.75/exc7200-touchscreen.fth \ Touchscreen driver and diagnostic
-
-fload ${BP}/cpu/arm/olpc/1.75/pinch.fth \ Touchscreen gestures
-: pinch " pinch" screen-ih $call-method ;
-
fload ${BP}/cpu/arm/mmp2/keypad.fth
[ifndef] cl2-a1
stand-init: keypad
@@ -210,6 +197,20 @@
;
fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
+
+fload ${BP}/dev/logdev.fth
+0 value smt-test? \ !!!
+0 value final-test? \ !!!
+fload ${BP}/cpu/x86/pc/olpc/disptest.fth
+fload ${BP}/dev/olpc/keyboard/selftest.fth \ Keyboard diagnostic
+fload ${BP}/dev/olpc/touchpad/syntpad.fth \ Touchpad diagnostic
+fload ${BP}/cpu/x86/pc/olpc/gridmap.fth \ Gridded display tools
+fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
+fload ${BP}/cpu/arm/olpc/1.75/exc7200-touchscreen.fth \ Touchscreen driver and diagnostic
+
+fload ${BP}/cpu/arm/olpc/1.75/pinch.fth \ Touchscreen gestures
+: pinch " pinch" screen-ih $call-method ;
+
: emacs ( -- )
false to already-go?
boot-getline to boot-file " rom:emacs" $boot
Modified: dev/olpc/keyboard/selftest.fth
==============================================================================
--- dev/olpc/keyboard/selftest.fth Wed May 25 23:41:47 2011 (r2224)
+++ dev/olpc/keyboard/selftest.fth Thu May 26 01:13:22 2011 (r2225)
@@ -575,6 +575,97 @@
false
;
+\ For XO-1.75, the game buttons are connected directly to the CPU SoC,
+\ instead of going through the EC. To preserve the rest of the test
+\ logic, we generate a stream of up-down events from the game button
+\ mask information.
+
+0 value pending-scancode \ One-byte queue for scancodes that follow an e0 prefix
+0 value pending-buttons \ Bitmask of button changes that haven't been sent yet
+0 value last-buttons \ State of game keys the last time we looked
+
+\ Finds the rightmost one bit in mask
+: choose-bit ( mask -- bit# )
+ d# 32 0 do ( mask )
+ dup 1 and if ( mask )
+ drop i unloop exit ( -- bit# )
+ then ( mask )
+ u2/ ( mask' )
+ loop ( mask )
+ drop -1 ( bit# ) \ Shouldn't happen
+;
+
+\ Maps bit number to scancode sequence
+
+create button-scancodes
+\ square check up down left right rotate o x
+\ 0 1 2 3 4 5 6 7 8
+ e067 w, e068 w, 65 w, 66 w, 67 w, 68 w, 69 w, e065 w, e066 w,
+
+\ If the scancode has an e0 prefix, bit#>scancode returns e0 and puts
+\ the suffix scancode in pending-scancode where it will be picked up
+\ the next time.
+: bit#>scancode ( bit# -- scancode )
+ button-scancodes over wa+ w@ ( bit# scancode )
+ \ Or in the 80 bit on an "up" transition
+ 1 rot lshift last-buttons and 0= if ( scancode )
+ h# 80 or ( scancode' )
+ then ( scancode )
+ dup h# ff00 and if ( scancode )
+ h# ff and to pending-scancode ( scancode )
+ h# e0 ( e0 )
+ then ( scancode )
+;
+
+\ Returns the next button-related scancode byte.
+: button-event? ( -- false | scancode true )
+ \ Handle the suffix of an e0-scancode sequence
+ pending-scancode if ( )
+ pending-scancode 0 to pending-scancode true ( scancode true )
+ exit ( -- scancode true )
+ then ( )
+
+ \ If the pending-buttons change mask is 0, we don't have anymore
+ \ events to generate from the last time around, so reread the
+ \ game buttons and set pending-buttons to the ones that have
+ \ changed.
+ pending-buttons 0= if
+ game-key@ ( new-buttons )
+ dup last-buttons xor to pending-buttons ( new-buttons )
+ to last-buttons ( )
+ then
+
+ \ If there are bits set in pending-buttons, generate an event from
+ \ the leftmost set bit and remove that bit from pending-buttons.
+ pending-buttons if ( )
+ \ Find the rightmost changed bit
+ pending-buttons choose-bit ( bit# )
+
+ \ Remove that bit from pending-buttons so it won't be reported again
+ 1 over lshift invert ( bit# clear-mask )
+ pending-buttons and to pending-buttons ( bit# )
+
+ \ Generate an up or down scancode sequence corresponding to that bit
+ dup bit#>scancode true ( scancode true )
+ else ( )
+ false ( false )
+ then ( false | scancode true )
+;
+
+\ Check for a change in button state if necessary.
+: or-button? ( [scancode] key? -- [scancode] flag )
+ \ If there is already a key from get-data?, handle it before checking the game buttons
+ dup if exit then ( [scancode] key? phandle )
+
+ \ If the /ec-spi device node is present, the game buttons are directly connected
+ \ so we must handle them here. Otherwise the EC will handle them and fold their
+ \ events into the keyboard scancode stream.
+ " /ec-spi" find-package if ( false phandle )
+ 2drop ( )
+ button-event? ( [scancode] flag )
+ then ( [scancode] flag )
+;
+
0 value last-timestamp
: selftest-keys ( -- )
false to esc?
@@ -584,8 +675,8 @@
final-test? smt-test? or if
key-stuck? if exit then
then
- get-data? if ( scancode )
- process-raw ( exit? )
+ get-data? or-button? if ( scancode )
+ process-raw ( exit? )
get-msecs to last-timestamp
else
final-test? smt-test? or if
Hi,
When I learn http://www.openfirmware.org/1275/practice/#graphics
I found that: I Can't get /pci/display ihandle under vbox, when I boot
up with usb-disk on my laptop, I can't get ihandle as well.
but I can get /pci/vga ihandle under qemu. And it works fine with
graphics.
--
Hu Songtao
works as an English Teacher in weekends
Skype: idisblueflash
Beijing, China