Author: wmb
Date: 2007-05-03 10:23:33 +0200 (Thu, 03 May 2007)
New Revision: 346
Added:
cpu/x86/pc/olpc/suspend.fth
Modified:
cpu/x86/pc/olpc/devices.fth
cpu/x86/pc/olpc/fw.bth
cpu/x86/pc/olpc/micin.fth
dev/olpc/touchpad/touchpad.fth
Log:
OLPC trac #1371 - Get board revision from EC. I revamped the board revision
sensing code, moving some distributed logic into one place. The word
"board-revision" now returns a number that has 3 digits when represented in hex.
The first 2 digits are the "conventional" board revision number, e.g. "B3",
and the third digit indicates build stages. Pre-B3 is h# B30 , first production
B3 will be B38, and subsequent variations might be B39, B3A, etc. In general,
the pre- version will have third digit 0 and the first production version will have
third digit 8. I did it this way so the numbers increase monotonically, to make
it easy to test for "a certain revision or later".
This checkin also adds a suspend/resume test to the touchpad tracking test. If
you type 's' while in the middle of the touchpad test, the system will suspend,
and when you resume it with the power button, the touchpad test continues.
Modified: cpu/x86/pc/olpc/devices.fth
===================================================================
--- cpu/x86/pc/olpc/devices.fth 2007-05-03 07:54:13 UTC (rev 345)
+++ cpu/x86/pc/olpc/devices.fth 2007-05-03 08:23:33 UTC (rev 346)
@@ -4,21 +4,6 @@
: gx? ( -- flag ) h# 4c000017 msr@ drop 4 rshift 2 = ;
: lx? ( -- flag ) h# 4c000017 msr@ drop 4 rshift 3 = ;
-: board-revision ( -- n )
- lx? if
- 1
-[ifdef] notyet
- h# fa20 ec@ case
- h# b2 of 0 endof
- h# b3 of 1 endof
- h# c1 of 2 endof
- endcase
-[then]
- else
- h# 4c00.0014 rdmsr drop 4 rshift 7 and
- then
-;
-
fload ${BP}/cpu/x86/pc/isaio.fth
[ifdef] rom-loaded
@@ -262,16 +247,26 @@
;
warning !
+: board-revision ( -- n )
+ atest? if h# a18 exit then
+ lx? if
+ board-id@ case
+ h# b2 of h# b30 endof \ preB3
+ ( board-id ) dup h# 10 * 8 + swap \ E.g. b3 -> b38
+ endcase
+ else
+ h# 4c00.0014 rdmsr drop ( RSTPLL-value )
+ 4 rshift 7 and 7 = if h# b28 else h# b18 then
+ then
+;
+
stand-init: PCI properties
" /pci" find-device
- atest? if
+ board-revision h# b18 < if
d# 33,333,333
else
- board-revision 7 = if
- d# 33,333,333
- else
- d# 66,666,667
- then
+ \ We switched to 66 MHz at B2
+ d# 66,666,667
then
" clock-frequency" integer-property
dend
Modified: cpu/x86/pc/olpc/fw.bth
===================================================================
--- cpu/x86/pc/olpc/fw.bth 2007-05-03 07:54:13 UTC (rev 345)
+++ cpu/x86/pc/olpc/fw.bth 2007-05-03 08:23:33 UTC (rev 346)
@@ -217,16 +217,19 @@
: stand-init
stand-init
root-device
- atest? if " A1" " OLPC A-test" else
- board-revision case
- 0 of " B2" " OLPC B2" endof
- 1 of " B3" " OLPC B3" endof
- 7 of " B1" " OLPC B1" endof
- ( default ) >r " ??" " OLPC ??" r>
- endcase
- then
+ board-revision case
+ h# a18 of " A1" " OLPC A-test" endof
+ h# b18 of " B1" " OLPC B1" endof
+ h# b28 of " B2" " OLPC B2" endof
+ h# b30 of " preB3" " OLPC preB3" endof
+ h# b38 of " B3" " OLPC B3" endof
+ h# b40 of " preB4" " OLPC preB4" endof
+ h# b48 of " B4" " OLPC B4" endof
+ ( default ) >r " ??" " OLPC ??" r>
+ endcase
encode-string " banner-name" property
model
+ board-revision " board-revision-int" integer-property
[ifndef] lx-devel
8 ec-cmd " ec-version" integer-property
@@ -270,13 +273,13 @@
[ifdef] lx-devel
h# 3ea exit \ USB4:PWR2 USB3:PWR1 USB2:PWR1 USB1:PWR1
[then]
- board-revision case
- 0 of h# 3ab endof \ B2 \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR2
- 1 of h# 3aa endof \ B3 \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR1
- 2 of h# 3aa endof \ C1 \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR1 (guess)
- 7 of h# 3ab endof \ B1
- ( default ) h# 3ab swap \ A - and early B1 (actually not switched, but no harm)
- endcase
+ board-revision h# b10 h# b2f between if \ B1 and B2
+ h# 3ab \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR2
+ else
+ \ A-test doesn't switch USB power, so the value doesn't matter.
+ \ preB3 and presumably later use this value
+ h# 3aa \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR1
+ then
;
fload ${BP}/cpu/x86/pc/olpc/usb.fth
@@ -361,6 +364,7 @@
[ifdef] olpc
fload ${BP}/cpu/x86/pc/olpc/gui.fth
+fload ${BP}/cpu/x86/pc/olpc/suspend.fth \ Suspend/resume setup
fload ${BP}/dev/olpc/keyboard/selftest.fth \ Keyboard diagnostic
fload ${BP}/dev/olpc/touchpad/touchpad.fth \ Touchpad diagnostic
fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports
@@ -422,27 +426,14 @@
: user-switch? ( -- flag )
[ifdef] lx-devel false exit [then]
- atest? if
- h# fc3f ec@ h# ff <>
- else
- \ The EC can tristate the KEY_OUT lines behind our back, so we
- \ try several times to observe a key press. Empirically, the EC
- \ takes about 1.5 mS to finish an (infrequent) scan.
- d# 5 0 do
- \ Output enable the KEY_OUT matrix lines
- h# fc12 ec@ dup h# e0 or h# fc12 ec! ( old )
- h# fc34 ec@ h# 70 and ( old keys )
- \ Output disable the KEY_OUT matrix lines
- swap h# e0 invert and h# fc12 ec! ( keys )
- h# 70 <> if true unloop exit then
- 2 ms
- loop
- false
+." Game key value is "
+ game-key@ dup . cr 0<> dup if
+ ." Release the game key to continue" cr
+ begin d# 100 ms game-key@ 0= until
then
;
: fast-boot? ( -- flag )
[ifdef] rom-loaded
-false exit
user-switch? 0=
[else]
false
@@ -504,36 +495,6 @@
" keyboard" open-dev ?dup if set-stdin then
;
-stand-init: Suspend/resume
- " resume" find-drop-in if
- suspend-base swap move
- msr-init-range ( adr len )
- resume-data h# 34 + ! ( adr )
- >physical resume-data h# 30 + ! ( )
- then
-;
-
-\ Useful for debugging suspend/resume problems
-\ : sum-forth ( -- ) 0 here origin do i c@ + loop . cr ;
-
-code ax-call ( ax-value dst -- ) bx pop ax pop bx call c;
-
-: s3
- \ Enable wakeup from power button, also clearing
- \ any status bits in the low half of the register.
- h# 1840 pl@ h# 100.0000 or h# 1840 pl!
-
-\ sum-forth
- [ also dev /mmu ] pdir-va h# f0000 ax-call [ previous definitions ]
-\ sum-forth
-;
-: suspend
- " video-save" stdout @ $call-method \ Freeze display
- s3
- " video-restore" stdout @ $call-method \ Unfreeze display
-;
-alias s suspend
-
: startup ( -- )
standalone? 0= if exit then
Modified: cpu/x86/pc/olpc/micin.fth
===================================================================
--- cpu/x86/pc/olpc/micin.fth 2007-05-03 07:54:13 UTC (rev 345)
+++ cpu/x86/pc/olpc/micin.fth 2007-05-03 08:23:33 UTC (rev 346)
@@ -4,10 +4,7 @@
\ This uses an undocumented register in the AD1888 codec.
\ It turns off the DC offset compensator.
-: post-b1? ( -- flag )
- atest? if false exit then \ atest is detected via EC type
- board-revision 0 6 between \ b1 is board revision 7
-;
+: post-b1? ( -- flag ) board-revision h# b10 >= ;
: ac-mode ( -- )
post-b1? if
Added: cpu/x86/pc/olpc/suspend.fth
===================================================================
--- cpu/x86/pc/olpc/suspend.fth (rev 0)
+++ cpu/x86/pc/olpc/suspend.fth 2007-05-03 08:23:33 UTC (rev 346)
@@ -0,0 +1,56 @@
+purpose: Setup and tests for suspend/resume to RAM
+\ See license at end of file
+
+stand-init: Suspend/resume
+ " resume" find-drop-in if
+ suspend-base swap move
+ msr-init-range ( adr len )
+ resume-data h# 34 + ! ( adr )
+ >physical resume-data h# 30 + ! ( )
+ then
+;
+
+\ Useful for debugging suspend/resume problems
+\ : sum-forth ( -- ) 0 here origin do i c@ + loop . cr ;
+
+code ax-call ( ax-value dst -- ) bx pop ax pop bx call c;
+
+: s3
+ \ Enable wakeup from power button, also clearing
+ \ any status bits in the low half of the register.
+ h# 1840 pl@ h# 100.0000 or h# 1840 pl!
+
+\ sum-forth
+ [ also dev /mmu ] pdir-va h# f0000 ax-call [ previous definitions ]
+\ sum-forth
+;
+: suspend
+ " video-save" stdout @ $call-method \ Freeze display
+ s3
+ " video-restore" stdout @ $call-method \ Unfreeze display
+;
+alias s suspend
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2007 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
Modified: dev/olpc/touchpad/touchpad.fth
===================================================================
--- dev/olpc/touchpad/touchpad.fth 2007-05-03 07:54:13 UTC (rev 345)
+++ dev/olpc/touchpad/touchpad.fth 2007-05-03 08:23:33 UTC (rev 346)
@@ -380,14 +380,21 @@
gs-only
begin
begin pad? if track then key? until
- key upc [char] P = dup if
- cursor-on
- cr last-10
- key drop
- background
- then
- 0= until
+ key upc case
+ [char] P of
+ cursor-on
+ cr last-10
+ key drop
+ background
+ false
+ endof
+ [char] S of suspend stream-on false endof
+
+ ( key ) true swap
+ endcase
+ until
+
close
0
;