Author: wmb Date: Tue Oct 4 02:42:45 2011 New Revision: 2573 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2573
Log: OLPC XO-1.75 - trac #11095 - implemented lid switch power-off.
Modified: cpu/arm/mmp2/timer.fth cpu/arm/olpc/1.75/switches.fth
Modified: cpu/arm/mmp2/timer.fth ============================================================================== --- cpu/arm/mmp2/timer.fth Tue Oct 4 02:05:46 2011 (r2572) +++ cpu/arm/mmp2/timer.fth Tue Oct 4 02:42:45 2011 (r2573) @@ -168,8 +168,13 @@ then ; code wfi ( -- ) wfi c; + +defer do-lid +: lid-off ( -- ) ['] noop to do-lid ; +lid-off + : safe-idle ( -- ) can-idle? if wfi then - \ do-lid + do-lid ; ' safe-idle to stdin-idle
Modified: cpu/arm/olpc/1.75/switches.fth ============================================================================== --- cpu/arm/olpc/1.75/switches.fth Tue Oct 4 02:05:46 2011 (r2572) +++ cpu/arm/olpc/1.75/switches.fth Tue Oct 4 02:42:45 2011 (r2573) @@ -36,6 +36,39 @@ ['] all-switch-states catch ;
+false value lid-already-down? +0 value lid-down-time +d# 10000 constant lid-shutdown-ms +d# 2000 constant lid-warning-ms +0 value lid-warned? + +: ?lid-shutdown ( -- ) + lid? if + lid-already-down? if + get-msecs lid-down-time - ( ms ) + + dup lid-warning-ms >= lid-warned? 0= and if + ." Lid switch is active - Powering off in 8 seconds" cr + ." Type lid-off to disable this function" cr + true to lid-warned? + then ( ms ) + + lid-shutdown-ms >= if + ." Powering off after 10 seconds of lid down" cr + power-off + then + else + get-msecs to lid-down-time + true to lid-already-down? + then + else + false to lid-already-down? + false to lid-warned? + then +; +: lid-on ( -- ) ['] ?lid-shutdown to do-lid ; +' lid-on to do-lid + end-package
\ LICENSE_BEGIN