Author: wmb Date: Fri Aug 31 01:42:31 2012 New Revision: 3258 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/3258
Log: OLPC ARM - Converted the RTC driver to use the new TWSI factoring, at the same time changing all occurrences of the method names "byte@" and "byte!" to "reg-b@" and "reg-b!".
Modified: cpu/arm/mmp2/twsi-node.fth cpu/arm/mmp2/twsi-package.fth cpu/arm/olpc/accelerometer.fth cpu/arm/olpc/rtc.fth
Modified: cpu/arm/mmp2/twsi-node.fth ============================================================================== --- cpu/arm/mmp2/twsi-node.fth Fri Aug 31 01:28:30 2012 (r3257) +++ cpu/arm/mmp2/twsi-node.fth Fri Aug 31 01:42:31 2012 (r3258) @@ -57,8 +57,8 @@
: get ( #bytes -- bytes ... ) 0 swap bytes-out-in ;
-: byte@ ( -- ) " byte@" $call-twsi ; -: byte! ( -- ) " byte!" $call-twsi ; +: reg-b@ ( reg# -- b ) " reg-b@" $call-twsi ; +: reg-b! ( b reg# -- ) " reg-b!" $call-twsi ; : bytes-out ( byte .. #bytes -- ) " bytes-out" $call-twsi ;
\ Useful range is 25K .. 400K - 100K and 400K are typical
Modified: cpu/arm/mmp2/twsi-package.fth ============================================================================== --- cpu/arm/mmp2/twsi-package.fth Fri Aug 31 01:28:30 2012 (r3257) +++ cpu/arm/mmp2/twsi-package.fth Fri Aug 31 01:42:31 2012 (r3258) @@ -136,8 +136,8 @@ bbu_ICR_STOP twsi-putbyte ( ) ;
-: byte@ ( reg -- byte ) 1 1 bytes-out-in ; -: byte! ( byte reg -- ) 2 bytes-out ; +: reg-b@ ( reg -- byte ) 1 1 bytes-out-in ; +: reg-b! ( byte reg -- ) 2 bytes-out ;
: set-bus-standard cr-set h# 18000 invert and to cr-set ; : set-bus-fast cr-set h# 18000 invert and h# 8000 or to cr-set ;
Modified: cpu/arm/olpc/accelerometer.fth ============================================================================== --- cpu/arm/olpc/accelerometer.fth Fri Aug 31 01:28:30 2012 (r3257) +++ cpu/arm/olpc/accelerometer.fth Fri Aug 31 01:42:31 2012 (r3258) @@ -9,8 +9,8 @@ \ This is for the stand-alone accelerometers LIS3DHTR and LIS33DETR
\ We could call this just once in open if we had a TWSI parent node -: acc-reg@ ( reg# -- b ) " byte@" $call-parent ; -: acc-reg! ( b reg# -- ) " byte!" $call-parent ; +: acc-reg@ ( reg# -- b ) " reg-b@" $call-parent ; +: acc-reg! ( b reg# -- ) " reg-b!" $call-parent ; : ctl1! ( b -- ) h# 20 acc-reg! ; : ctl4! ( b -- ) h# 23 acc-reg! ; : accelerometer-on ( -- ) h# 47 ctl1! ;
Modified: cpu/arm/olpc/rtc.fth ============================================================================== --- cpu/arm/olpc/rtc.fth Fri Aug 31 01:28:30 2012 (r3257) +++ cpu/arm/olpc/rtc.fth Fri Aug 31 01:42:31 2012 (r3258) @@ -2,23 +2,13 @@
dev /i2c@d4031000 \ TWSI2 new-device - " rtc" name - " idt,idt1338-rtc" +compatible - h# 68 1 reg - -[ifdef] cl2-a1 -: set-address ( -- ) - rtc-scl-gpio# to smb-clock-gpio# - rtc-sda-gpio# to smb-data-gpio# - h# 68 to smb-slave -; -: rtc@ ( reg# -- byte ) set-address smb-byte@ ; -: rtc! ( byte reg# -- ) set-address smb-byte! ; -[else] -: set-address ( -- ) h# 68 2 set-twsi-target ; -: rtc@ ( reg# -- byte ) set-address twsi-b@ ; -: rtc! ( byte reg# -- ) set-address twsi-b! ; -[then] + +" rtc" name +" idt,idt1338-rtc" +compatible +h# 68 1 reg + +: rtc@ ( reg# -- byte ) " reg-b@" $call-parent ; +: rtc! ( byte reg# -- ) " reg-b!" $call-parent ;
headerless
@@ -33,6 +23,8 @@
headers : open ( -- okay ) + my-unit " set-address" $call-parent + 0 ['] rtc@ catch if ( x ) drop false exit ( -- false ) then ( value ) @@ -58,12 +50,7 @@ : >bcd ( binary -- bcd ) d# 10 /mod 4 << + ;
: bcd-time&date ( -- s m h d m y century ) - set-address -[ifdef] cl2-a1 - 9 0 smb-read-n ( s m h dow d m y control c ) -[else] - 0 1 9 twsi-get ( s m h dow d m y control c ) -[then] + 0 1 9 " bytes-out-in" $call-parent ( s m h dow d m y control c ) nip ( s m h dow d m y c ) 4 roll drop ( s m h d m y c ) ;
openfirmware@openfirmware.info