Author: wmb
Date: 2007-10-23 03:18:40 +0200 (Tue, 23 Oct 2007)
New Revision: 694
Added:
cpu/x86/pc/olpc/wlantest.fth
Modified:
cpu/x86/pc/olpc/fw.bth
cpu/x86/pc/olpc/rtcwake.fth
dev/usb2/device/wlan/usb8388.fth
Log:
OLPC - Added rtc-wackup command for suspend-resume testing, and
made it slightly easier to include the WLAN version of auto-wakeup.
Modified: cpu/x86/pc/olpc/fw.bth
===================================================================
--- cpu/x86/pc/olpc/fw.bth 2007-10-23 00:59:11 UTC (rev 693)
+++ cpu/x86/pc/olpc/fw.bth 2007-10-23 01:18:40 UTC (rev 694)
@@ -336,6 +336,10 @@
fload ${BP}/ofw/gui/ofpong.fth
fload ${BP}/cpu/x86/pc/olpc/life.fth
fload ${BP}/cpu/x86/pc/olpc/sound.fth
+[ifdef] wlan-wackup
+fload ${BP}/cpu/x86/pc/olpc/wlantest.fth
+[then]
+fload ${BP}/cpu/x86/pc/olpc/rtcwake.fth
' gx-power-off to power-off
[then]
@@ -384,6 +388,7 @@
then
ec-reboot \ Tell the EC to reboot us, so the EC can reset too
+ begin again
;
' dcon-reset-all to reset-all
Modified: cpu/x86/pc/olpc/rtcwake.fth
===================================================================
--- cpu/x86/pc/olpc/rtcwake.fth 2007-10-23 00:59:11 UTC (rev 693)
+++ cpu/x86/pc/olpc/rtcwake.fth 2007-10-23 01:18:40 UTC (rev 694)
@@ -1,16 +1,33 @@
-\ Suspend/resume test with RTC wakeup
-d# 2 value rtc-alarm-delay
+purpose: Suspend/resume test with RTC wakeup
+\ See license at end of file
-h# 41 constant cmos-alarm-day \ CMOS offset of day alarm
-h# 40 constant cmos-alarm-month \ CMOS offset of month alarm
-cmos-alarm-day 0 h# 5140.0055 msr!
-cmos-alarm-month 0 h# 5140.0056 msr!
+: enable-rtc-irq ( -- ) h# a1 pc@ h# fe and h# a1 pc! ;
+: disable-rtc-irq ( -- ) h# a1 pc@ 1 or h# a1 pc! ;
+0 value cmos-alarm-day \ Offset of day alarm in CMOS
+0 value cmos-alarm-month \ Offset of month alarm in CMOS
+
+: set-alarm-offsets ( -- )
+ h# 10. h# 5140.0055 wrmsr
+ h# 11. h# 5140.0056 wrmsr
+
+ h# 5140.0055 rdmsr drop to cmos-alarm-day
+ h# 5140.0056 rdmsr drop to cmos-alarm-month
+;
+
+false value enable-rtc-irq?
+
+: rtc-handler ( -- ) h# c cmos@ drop ." R" ; \ Clear RTC interrupt flags
+
: enable-rtc-alarm ( -- )
+ ['] rtc-handler 8 interrupt-handler!
+
+ enable-rtc-irq? if enable-rtc-irq then
h# c cmos@ drop \ Clear RTC interrupt flags
h# b cmos@ h# 20 or h# b cmos!
;
: disable-rtc-alarm ( -- )
+ disable-rtc-irq
h# b cmos@ h# 20 invert and h# b cmos!
;
: bcd-cmos! ( binary -- ) " bcd!" clock-node @ $call-method ;
@@ -24,13 +41,42 @@
5 bcd-cmos! 3 bcd-cmos! 1 bcd-cmos! ( )
enable-rtc-alarm
;
-
-: rs ( -- )
+d# 1 constant rtc-alarm-delay
+: pm-sleep-rtc ( -- )
+ false to enable-rtc-irq? \ Spec says that IRQ is not necessary
rtc-alarm-delay set-rtc-alarm
+ h# 400.0000 0 acpi-l! \ Enable RTC SCI
s
disable-rtc-alarm
+ 0 0 acpi-l! \ Disable RTC SCI
;
-patch 500.0000 100.0000 s3 \ Turn on RTC wakeup too
-: rss begin d# 50 ms rs ." ." key? until ;
+: rtc-wackup
+ set-alarm-offsets
+ 0
+ begin pm-sleep-rtc space dup . (cr 1+ key? until
+ key drop
+;
-.( 'rs' does it once, 'rss' does it until you type a key) cr
+\ 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
Added: cpu/x86/pc/olpc/wlantest.fth
===================================================================
--- cpu/x86/pc/olpc/wlantest.fth (rev 0)
+++ cpu/x86/pc/olpc/wlantest.fth 2007-10-23 01:18:40 UTC (rev 694)
@@ -0,0 +1,29 @@
+purpose: Wireless LAN auto-wakeup (requires modified WLAN firmware)
+
+0 value patched?
+: wackup
+ patched? 0= if
+ " /wlan" find-device
+ " patch exit link-up? close" evaluate
+ dend
+ true to patched?
+ then
+
+ sci-wakeup
+
+ " /wlan" open-dev >r
+ " broadcast-wakeup" r@ $call-method
+ r> close-dev
+
+ 0
+ begin
+ " /wlan" open-dev >r
+ " autostart" r@ $call-method
+ " sleep" r@ $call-method
+ r> close-dev
+ 5 ms
+ s
+ 1+ dup .
+ d# 500 ms
+ key? until
+;
Modified: dev/usb2/device/wlan/usb8388.fth
===================================================================
--- dev/usb2/device/wlan/usb8388.fth 2007-10-23 00:59:11 UTC (rev 693)
+++ dev/usb2/device/wlan/usb8388.fth 2007-10-23 01:18:40 UTC (rev 694)
@@ -1164,7 +1164,7 @@
: broadcast-wakeup ( -- ) wake-on-unicast wake-on-broadcast or host-sleep-config ;
: sleep ( -- ) host-sleep-activate ;
-[ifdef] notdef \ This is test code that only works with a special debug version of the Libertas firmware
+[ifdef] wlan-wackup \ This is test code that only works with a special debug version of the Libertas firmware
: autostart ( -- )
h# 82 h# 9b ( CMD_MESH_ACCESS ) prepare-cmd
5 +xw \ CMD_ACT_SET_ANYCAST