Author: wmb Date: Thu Nov 25 03:31:28 2010 New Revision: 2038 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2038
Log: OLPC XO-1.75 - (1) Startup sound now plays in the background for faster startup (2) Use 3.3V signals GPIO 97,98 for RTC (bitbanging instead of using the TWSI hardware) (3) Made the startup sequence more like the 1.5 version
Modified: cpu/arm/forthint.fth cpu/arm/olpc/1.75/boardgpio.fth cpu/arm/olpc/1.75/fw.bth cpu/arm/olpc/1.75/rtc.fth cpu/arm/olpc/1.75/sound.fth cpu/x86/pc/olpc/security.fth
Modified: cpu/arm/forthint.fth ============================================================================== --- cpu/arm/forthint.fth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/arm/forthint.fth Thu Nov 25 03:31:28 2010 (r2038) @@ -145,7 +145,7 @@ interrupt-preamble 6 install-handler init-dispatcher [ previous ] - d# 10 set-tick-limit + d# 1 set-tick-limit enable-interrupts \ Turn interrupts on ;
Modified: cpu/arm/olpc/1.75/boardgpio.fth ============================================================================== --- cpu/arm/olpc/1.75/boardgpio.fth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/arm/olpc/1.75/boardgpio.fth Thu Nov 25 03:31:28 2010 (r2038) @@ -23,6 +23,8 @@ d# 58 gpio-set \ WLAN_RESET# d# 58 gpio-dir-out \ WLAN_RESET# d# 73 gpio-dir-out \ CAM_RST + d# 97 gpio-dir-out \ RTC_SCK + d# 98 gpio-dir-out \ RTC_SDA
d# 125 gpio-set d# 125 gpio-dir-out \ EC_SPI_ACK @@ -90,10 +92,10 @@ no-update, \ GPIO_50 - Not connected (TP114) no-update, \ GPIO_51 - Not connected (TP59) no-update, \ GPIO_52 - Not connected (TP113) - 2 af, \ GPIO_53 - RTC_SCK (TWSI2) if R124 populated - 2 af, \ GPIO_54 - RTC_SDA (TWSI2) if R125 populated -\ no-update, \ GPIO_53 - Not connected if nopop R124 to use TWSI6 for RTC -\ no-update, \ GPIO_54 - Not connected if nopop R125 to use TWSI6 for RTC +\ 2 af, \ GPIO_53 - RTC_SCK (TWSI2) if R124 populated +\ 2 af, \ GPIO_54 - RTC_SDA (TWSI2) if R125 populated + no-update, \ GPIO_53 - Not connected if nopop R124 to use TWSI6 for RTC + no-update, \ GPIO_54 - Not connected if nopop R125 to use TWSI6 for RTC no-update, \ GPIO_55 - Not connected (TP51) no-update, \ GPIO_56 - Not connected (TP60) 0 af, \ GPIO_57 - WLAN_PD# @@ -141,10 +143,12 @@
no-update, \ GPIO_96 - Not connected (TP112)
- no-update, \ GPIO_97 - Not connected (R100 nopop) if we use TWSI2 for RTC - no-update, \ GPIO_98 - Not connected (R106 nopop) if we use TWSI2 for RTC +\ no-update, \ GPIO_97 - Not connected (R100 nopop) if we use TWSI2 for RTC +\ no-update, \ GPIO_98 - Not connected (R106 nopop) if we use TWSI2 for RTC \ 2 af, \ GPIO_97 - RTC_SCK (TWSI6) if R100 populated \ 2 af, \ GPIO_98 - RTC_SDA (TWSI6) if R106 populated + 0 af, \ GPIO_97 - RTC_SCK (bitbang) if R100 populated + 0 af, \ GPIO_98 - RTC_SDA (bitbang) if R106 populated
0 af, \ GPIO_99 - TOUCH_SCR_INT 0 af, \ GPIO_100 - DCONSTAT0
Modified: cpu/arm/olpc/1.75/fw.bth ============================================================================== --- cpu/arm/olpc/1.75/fw.bth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/arm/olpc/1.75/fw.bth Thu Nov 25 03:31:28 2010 (r2038) @@ -167,8 +167,14 @@ : ec-indexed-io-off ( -- ) ; \ !!! : ec-ixio-reboot ( -- ) ; \ !!! : flash-base ( -- ) true abort" The stuff that relies on flash-base in security.fth needs to be reworked!" ; -: cmos@ ( index -- data ) h# 38 mod 8 + " rtc@" clock-node @ $call-method ; -: cmos! ( index data -- ) h# 38 mod 8 + " rtc!" clock-node @ $call-method ; +: cmos@ ( index -- data ) + h# 38 mod 8 + " rtc@" clock-node @ ( index adr len ih ) + ['] $call-method catch if 4drop 0 then +; +: cmos! ( data index -- ) + h# 38 mod 8 + " rtc!" clock-node @ ( data index adr len ih ) + ['] $call-method if 2drop 3drop then +; : halt ( -- ) c7-wfi ; fload ${BP}/cpu/x86/pc/olpc/sound.fth fload ${BP}/cpu/x86/pc/olpc/security.fth @@ -201,7 +207,7 @@ \needs ramdisk " " d# 128 config-string ramdisk " " ' boot-file set-config-string-default \ Let the boot script set the cmdline
-2 config-int auto-boot-countdown +3 config-int auto-boot-countdown
\ Eliminate 4 second delay in install console for the case where \ there is no keyboard. The delay is unnecessary because the screen @@ -227,7 +233,7 @@
: console-start ( -- ) install-mux-io -\ cursor-off + cursor-off true to text-on?
" //null" open-dev to null-ih \ For text-off state @@ -244,9 +250,7 @@ warning on only forth also definitions
- show-child install-alarm - ['] sound catch drop
page-mode #line off @@ -254,6 +258,18 @@ \ .built cr ;
+ +: factory-test? ( -- flag ) + \ TS is the "test station" tag, whose value is set to "SHIP" at the + \ end of manufacturing test. + " TS" find-tag if ( adr len ) + ?-null " SHIP" $= 0= ( in-factory? ) + else ( ) + \ Missing TS tag is treated as not in factory test + false + then ( in-factory? ) +; + [ifdef] notyet : ?games ( -- ) rocker-right game-key? if @@ -289,26 +305,32 @@ : startup ( -- ) standalone? 0= if exit then
-\ block-exceptions + block-exceptions no-page
+ ?factory-mode + + disable-user-aborts console-start
[ifdef] notyet read-game-keys [then]
-\ text-off + factory-test? if text-off then
" probe-" do-drop-in
+ show-child + install-alarm + ['] sound catch drop [ifdef] notyet - sound ?games [then]
['] false to interrupt-auto-boot? [ifdef] probe-usb + factory-test? if d# 1000 ms then \ Extra USB probe delay in the factory probe-usb report-disk report-keyboard @@ -317,19 +339,31 @@
interpreter-init [ifdef] notyet - ?scan-nand ?diags +[ifdef] Later + ?scan-nand +[then] ?fs-update [then] -\ unblock-exceptions + factory-test? 0= if secure-startup then + unblock-exceptions ['] (interrupt-auto-boot?) to interrupt-auto-boot? -\ ?usb-keyboard +[ifdef] notyet + ?usb-keyboard +[then] auto-banner? if banner then
auto-boot
+ frozen? text-on? 0= and ( no-banner? ) + unfreeze visible ( no-banner? ) + if banner then \ Reissue banner if it was suppressed + + blue-letters ." Type 'help' for more information." black-letters cr cr
+ enable-user-aborts + stop-sound quit ;
Modified: cpu/arm/olpc/1.75/rtc.fth ============================================================================== --- cpu/arm/olpc/1.75/rtc.fth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/arm/olpc/1.75/rtc.fth Thu Nov 25 03:31:28 2010 (r2038) @@ -1,9 +1,13 @@ 0 0 " " " /" begin-package " rtc" name
-: set-address ( -- ) h# d0 2 set-twsi-target ; -: rtc@ ( reg# -- byte ) set-address twsi-b@ ; -: rtc! ( byte reg# -- ) set-address twsi-b! ; +: set-address ( -- ) + d# 97 to smb-clock-gpio# + d# 98 to smb-data-gpio# + h# d0 to smb-slave +; +: rtc@ ( reg# -- byte ) set-address smb-byte@ ; +: rtc! ( byte reg# -- ) set-address smb-byte! ;
headerless
@@ -21,8 +25,8 @@ : >bcd ( binary -- bcd ) d# 10 /mod 4 << + ;
: bcd-time&date ( -- s m h d m y century ) - 0 1 7 twsi-get ( s m h dow d m y ) - 3 roll drop ( s m h dow d m y ) + 7 0 smb-read-n ( s m h dow d m y ) + 3 roll drop ( s m h dow d m y ) d# 20 ; : bcd! ( n offset -- ) swap >bcd swap rtc! ;
Modified: cpu/arm/olpc/1.75/sound.fth ============================================================================== --- cpu/arm/olpc/1.75/sound.fth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/arm/olpc/1.75/sound.fth Thu Nov 25 03:31:28 2010 (r2038) @@ -123,7 +123,7 @@ : set-descriptor ( next dest source length adr -- ) >r r@ l! r@ la1+ l! r@ 2 la+ l! r> 3 la+ l! ; -: make-out-ring ( adr len -- ) +: make-out-ring ( -- ) out-desc h# 10 + sspa-base h# 80 + out-bufs /audio-buf out-desc set-descriptor out-desc sspa-base h# 80 + out-bufs /audio-buf + /audio-buf out-desc h# 10 + set-descriptor out-desc h# 30 adma! \ Link to first descriptor @@ -133,7 +133,9 @@ 1 h# 80 adma! \ Enable DMA completion interrupts h# 0081.3020 h# 40 adma! \ 16 bits, pack, fetch next, enable, chain, hold dest, inc src ; -: make-in-ring ( adr len -- ) +: stop-out-ring ( -- ) h# 100000 h# 40 adma! ; + +: make-in-ring ( -- ) in-desc h# 10 + in-bufs sspa-base /audio-buf in-desc set-descriptor in-desc in-bufs /audio-buf + sspa-base /audio-buf in-desc h# 10 + set-descriptor in-desc h# 34 adma! \ Link to first descriptor @@ -252,7 +254,6 @@ : close-in ( -- ) ; : open-out ( -- ) setup-sspa-tx ; : close-out ( -- ) ; -: write-done ( -- ) ;
: wait-out ( -- ) buf-timeout 0 do @@ -260,20 +261,84 @@ loop 0 h# a0 adma! ; -: audio-out ( adr len -- actual ) - tuck to out-len to out-adr + +defer playback-alarm +0 value alarmed? + +: install-playback-alarm ( -- ) + true to alarmed? ['] playback-alarm d# 3 alarm +; +: uninstall-playback-alarm ( -- ) + alarmed? if + ['] playback-alarm d# 0 alarm + false to alarmed? + then +; + +false value playing? + +: stop-out ( -- ) + disable-sspa-tx + stop-out-ring + uninstall-playback-alarm + false to playing? +; + +: ?end-playing ( -- ) + h# a0 adma@ 1 and 0= if exit then + 0 h# a0 adma! + out-len if copy-out then + h# 40 adma@ h# 4000 and 0= if + stop-out + then +; +: playback-continue-alarm ( -- ) + playing? if + ?end-playing + else + \ If playback has already stopped as a result of + \ someone else having waited for completion, we + \ just uninstall ourself. + uninstall-playback-alarm + then +; +' playback-continue-alarm to playback-alarm + +: start-audio-out ( adr len -- ) + to out-len ( adr ) + to out-adr ( ) make-out-ring copy-out start-out-ring enable-sspa-tx - begin out-len while - copy-out - wait-out - repeat - wait-out - disable-sspa-tx + out-len if copy-out then \ Prefill the second buffer + install-playback-alarm + true to playing? +; + +: audio-out ( adr len -- actual ) tuck start-audio-out ; + +: stop-sound ( -- ) + lock[ + playing? if stop-out then + ]unlock +; + +0 value time-limit +: set-time-limit ( ms -- ) get-msecs + to time-limit ; +: 1sec-time-limit ( -- ) d# 1000 set-time-limit ; +: ?timeout ( -- ) + get-msecs time-limit - 0> if + ." Audio device timeout!" cr + abort + then +; +: wait-out-done ( -- ) + d# 20,000 set-time-limit begin ?timeout playing? 0= until ; -: write ( adr len -- actual ) open-out audio-out ; +: write-done ( -- ) wait-out-done stop-out ; + +: write ( adr len -- actual ) open-out audio-out ;
: wait-in ( -- ) buf-timeout 0 do @@ -294,8 +359,11 @@ ; : read ( adr len -- actual ) open-in audio-in ;
-: wait-sound ( -- ) ; -: stop-sound ( -- ) ; +: wait-sound ( -- ) + lock[ + begin playing? while d# 10 ms ?end-playing repeat + ]unlock +;
0 [if] \ Notes: @@ -441,8 +509,7 @@ : stereo ; : mono ;
-: open ( -- flag ) - audio-clock-on +: init-codec ( -- ) codec-on headphones-inserted? if select-headphones else select-speakers then default-speaker-volume set-speaker-volume @@ -451,9 +518,19 @@ default-mic-gain set-mic-gain default-adc-gain set-adc-gain d# 48000 set-sample-rate +; +0 value open-count +: open ( -- flag ) + open-count 0= if audio-clock-on init-codec then + open-count 1+ to open-count true ; -: close ( -- ) ; +: close ( -- ) + open-count 1 = if + uninstall-playback-alarm codec-off ( audio-clock-off ) + then + open-count 1- 0 max to open-count +;
fload ${BP}/forth/lib/isin.fth fload ${BP}/forth/lib/tones.fth
Modified: cpu/x86/pc/olpc/security.fth ============================================================================== --- cpu/x86/pc/olpc/security.fth Thu Nov 25 00:38:16 2010 (r2037) +++ cpu/x86/pc/olpc/security.fth Thu Nov 25 03:31:28 2010 (r2038) @@ -328,7 +328,8 @@
: date-bad? ( -- flag ) current-seconds 0= if - time&date >unix-seconds to current-seconds + ['] time&date catch if true exit then + >unix-seconds to current-seconds then
\ earliest is the earliest acceptable date value (in seconds).
openfirmware@openfirmware.info