Author: quozl Date: Thu Feb 14 02:07:23 2013 New Revision: 3546 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3546
Log: OLPC - lid and ebook switch tests, move to a common file
Added: dev/olpc/lidtest.fth Modified: cpu/arm/olpc/1.75/switches.fth cpu/arm/olpc/cl4/switches.fth cpu/x86/pc/olpc/via/switches.fth
Modified: cpu/arm/olpc/1.75/switches.fth ============================================================================== --- cpu/arm/olpc/1.75/switches.fth Wed Feb 13 08:40:27 2013 (r3545) +++ cpu/arm/olpc/1.75/switches.fth Thu Feb 14 02:07:23 2013 (r3546) @@ -9,38 +9,11 @@ lid-switch-gpio# 1 " lid-gpios" gpio-property
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 -; +: lid? ( -- flag ) lid-switch-gpio# gpio-pin@ 0= ; +: ebook? ( -- flag ) ebook-mode-gpio# gpio-pin@ 0= ;
+fload ${BP}/dev/olpc/lidtest.fth fload ${BP}/dev/olpc/lid.fth end-package
Modified: cpu/arm/olpc/cl4/switches.fth ============================================================================== --- cpu/arm/olpc/cl4/switches.fth Wed Feb 13 08:40:27 2013 (r3545) +++ cpu/arm/olpc/cl4/switches.fth Thu Feb 14 02:07:23 2013 (r3546) @@ -10,38 +10,11 @@ lid-switch-gpio# 1 " lid-gpios" gpio-property
0 0 reg \ So test-all will run the test -: open ( -- okay? ) true ; -: close ( -- ) ; -: lid? ( -- flag ) d# 129 gpio-pin@ 0= ; -: ebook? ( -- flag ) d# 130 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 -; +: lid? ( -- flag ) lid-switch-gpio# gpio-pin@ 0= ; +: ebook? ( -- flag ) ebook-mode-gpio# gpio-pin@ 0= ;
+fload ${BP}/dev/olpc/lidtest.fth fload ${BP}/dev/olpc/lid.fth end-package
Modified: cpu/x86/pc/olpc/via/switches.fth ============================================================================== --- cpu/x86/pc/olpc/via/switches.fth Wed Feb 13 08:40:27 2013 (r3545) +++ cpu/x86/pc/olpc/via/switches.fth Thu Feb 14 02:07:23 2013 (r3546) @@ -3,39 +3,13 @@
0 0 " 0" " /" begin-package " switches" device-name + 0 0 reg \ So test-all will run the test -: open ( -- okay? ) true ; -: close ( -- ) ; + : lid? ( -- flag ) h# 48 acpi-l@ h# 80 and 0= ; : ebook? ( -- flag ) h# 48 acpi-l@ h# 200 and 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 -; - +fload ${BP}/dev/olpc/lidtest.fth end-package
\ LICENSE_BEGIN
Added: dev/olpc/lidtest.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ dev/olpc/lidtest.fth Thu Feb 14 02:07:23 2013 (r3546) @@ -0,0 +1,55 @@ +\ See license at end of file +purpose: selftest for OLPC lid and ebook switches + +: open ( -- okay? ) true ; +: close ( -- ) ; +: ?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 +; + +\ LICENSE_BEGIN +\ Copyright (c) 2013 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
openfirmware@openfirmware.info