Author: wmb
Date: Thu Oct 13 03:07:05 2011
New Revision: 2599
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2599
Log:
OLPC XO-1.75 - support for new accelerometer chip.
Modified:
cpu/arm/olpc/1.75/accelerometer.fth
cpu/arm/olpc/1.75/roller.fth
Modified: cpu/arm/olpc/1.75/accelerometer.fth
==============================================================================
--- cpu/arm/olpc/1.75/accelerometer.fth Wed Oct 12 23:49:29 2011 (r2598)
+++ cpu/arm/olpc/1.75/accelerometer.fth Thu Oct 13 03:07:05 2011 (r2599)
@@ -1,9 +1,8 @@
-
hex
-0 0 " 6,3a" " /twsi" begin-package
+0 0 " " " /twsi" begin-package
" accelerometer" name
-my-address my-space encode-phys " reg" property
+\ my-address my-space encode-phys " reg" property
\ This is for the stand-alone accelerometer chip LIS33DETR
@@ -11,15 +10,18 @@
: acc-reg@ ( reg# -- b ) 1 1 " smbus-out-in" $call-parent ;
: acc-reg! ( b reg# -- ) 2 0 " smbus-out-in" $call-parent ;
: ctl1! ( b -- ) h# 20 acc-reg! ;
+: ctl4! ( b -- ) h# 23 acc-reg! ;
: accelerometer-on ( -- ) h# 47 ctl1! ;
: accelerometer-off ( -- ) h# 07 ctl1! ;
: bext ( b -- n ) dup h# 80 and if h# ffffff00 or then ;
+: wext ( b -- n ) dup h# 8000 and if h# ffff0000 or then ;
: acceleration@ ( -- x y z )
- h# 29 acc-reg@ bext
- h# 2b acc-reg@ bext
- h# 2d acc-reg@ bext
+ h# 28 acc-reg@ h# 29 acc-reg@ bwjoin wext 5 >>a
+ h# 2a acc-reg@ h# 2b acc-reg@ bwjoin wext 5 >>a
+ h# 2c acc-reg@ h# 2d acc-reg@ bwjoin wext 5 >>a
;
+
: t+ ( x1 y1 z1 x2 y2 z2 -- x3 y3 z3 )
>r >r >r ( x1 y1 z1 r: z2 y2 x2 )
rot r> + ( y1 z1 x3 r: z2 y2 )
@@ -35,12 +37,12 @@
\ Averaging a lot of samples reduces the effect of vibration
: average-acceleration@ ( -- x y z )
acceleration@ ( x y z )
- d# 127 0 do
+ d# 64 0 do
acceleration@ t+ ( x' y' z' )
loop
- rot 7 >>a
- rot 7 >>a
- rot 7 >>a
+ rot 6 >>a
+ rot 6 >>a
+ rot 6 >>a
;
: delay ( -- ) d# 30 ms ;
@@ -60,25 +62,28 @@
\ - Mitch's unit, 32
\ - James' A3, 41 (on rubber mat on bare ground)
\ - James' A2, 39
-d# 50 value max-delta
-: out-of-range? ( delta -- error? ) 3 max-delta between 0= ;
+
+d# 50 value min-x
+d# 50 value min-y
+d# 150 value min-z
+d# 100 value max-x
+d# 100 value max-y
+d# 300 value max-z
+: range? ( delta max-delta -- error? ) between 0= ;
: error? ( dx dy dz -- error? )
- out-of-range? if ." X axis error" cr 2drop true exit then ( dx dy )
- out-of-range? if ." Y axis error" cr drop true exit then ( dx )
- out-of-range? if ." X axis error" cr true exit then ( )
+ min-z max-z range? if ." Z axis error" cr 2drop true exit then ( dx dy )
+ min-y max-y range? if ." Y axis error" cr drop true exit then ( dx )
+ min-x max-x range? if ." X axis error" cr true exit then ( )
false
;
-: selftest ( -- error? )
- open 0= if true exit then
-
- final-test? if accelerometer-off false exit then
-
+: lis33de-selftest ( -- error? )
\ Use the device's selftest function to force a change in one direction
delay ( )
average-acceleration@ ( x y z )
- h# 4f ctl1! delay ( x y z ) \ Set the STM bit
+ h# 4f ctl1! ( x y z ) \ Set the STM bit
+ delay
average-acceleration@ t- ( dx dy dz )
\ STM applies negative bias to Y, but our deltas are inverted
\ because we subtract the new measurement from the old.
@@ -89,15 +94,70 @@
\ Use the device's selftest function to force a change in the opposite direction
accelerometer-on delay ( ) \ Back to normal - STM and STP both off
average-acceleration@ ( x y z )
- h# 57 ctl1! delay ( x y z ) \ Set the STP bit
+ h# 57 ctl1! ( x y z ) \ Set the STP bit
+ delay
average-acceleration@ t- ( dx dy dz )
\ STP applies negative bias to X and Z, but our deltas are inverted
\ because we subtract the new measurement from the old.
swap negate swap ( dx dy' dz )
error? if accelerometer-off true exit then
+ false
+;
+: lis3dhtr-selftest ( -- )
+ \ Use the device's selftest function to force a change in one direction
+ delay ( )
+ average-acceleration@ ( x y z )
+ h# 0a ctl4! ( x y z ) \ High res, Selftest mode 0
+ delay
+ average-acceleration@ t- ( dx dy dz )
+ rot negate rot negate rot negate
+ h# 08 ctl4! ( x y z ) \ High res, Normal mode
+ error? if accelerometer-off true exit then
+
+ \ Use the device's selftest function to force a change in the opposite direction
+ accelerometer-on delay ( ) \ Back to normal - STM and STP both off
+ average-acceleration@ ( x y z )
+ h# 0c ctl4! ( x y z ) \ High res, Selftest mode 1
+ delay
+ average-acceleration@ t- ( dx dy dz )
+ h# 08 ctl4! ( x y z ) \ High res, Normal mode
+ error? if accelerometer-off true exit then
accelerometer-off
false
;
+defer lis-selftest
+: selftest ( -- error? )
+ open 0= if true exit then
+
+ final-test? if accelerometer-off false exit then
+
+ lis-selftest
+;
+
+: probe ( -- )
+ h# 3a 6 " set-address" $call-parent
+ d# 25,000 " set-bus-speed" $call-parent
+ ['] accelerometer-on catch if
+ \ The attempt to talk at the old address failed, so we assume the new chip
+ \ Support for new LIS3DHTR chip
+ d# 50 to min-x d# 50 to min-y d# 50 to min-z
+ d# 150 to max-x d# 150 to max-y d# 300 to max-z
+ h# 32 6 encode-phys " reg" property
+ ['] lis3dhtr-selftest to lis-selftest
+ else
+ accelerometer-off
+ \ Something responded to the old address, so we assume it's the old chip
+ \ Support for old LIS33DE chip
+ d# 20 to min-x d# 20 to min-y d# 20 to min-z
+ d# 400 to max-x d# 400 to max-y d# 400 to max-z
+ h# 3a 6 encode-phys " reg" property
+ ['] lis33de-selftest to lis-selftest
+ then
+;
end-package
+
+stand-init: Accelerometer
+ " /accelerometer" " probe" execute-device-method drop
+;
Modified: cpu/arm/olpc/1.75/roller.fth
==============================================================================
--- cpu/arm/olpc/1.75/roller.fth Wed Oct 12 23:49:29 2011 (r2598)
+++ cpu/arm/olpc/1.75/roller.fth Thu Oct 13 03:07:05 2011 (r2599)
@@ -75,7 +75,7 @@
d# 19 d# 20 a/b>fraction value damping
-d# 1 d# 10 a/b>fraction value acc-scale
+d# 1 d# 80 a/b>fraction value acc-scale
d# 20 constant ball-radius
d# 40 constant ball-diameter
Author: wmb
Date: Wed Oct 12 23:49:29 2011
New Revision: 2598
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2598
Log:
OLPC XO-1.75 - trac # 11329 - Eliminated, or at least greatly reduced, pops at the beginning and end of the startup sound. The beginning pop was fixed by reordering the CODEC power-up sequence so the DAC is turned on before the output amp. The ending pop was fixed by appending zeros to the upsampling buffer so the filter does not pick up unrelated garbage after the end.
Modified:
cpu/arm/firfilter.fth
cpu/arm/olpc/1.75/alc5631.fth
cpu/arm/olpc/1.75/sound.fth
Modified: cpu/arm/firfilter.fth
==============================================================================
--- cpu/arm/firfilter.fth Wed Oct 12 23:27:50 2011 (r2597)
+++ cpu/arm/firfilter.fth Wed Oct 12 23:49:29 2011 (r2598)
@@ -21,7 +21,9 @@
\ Taps/phase=16
\ Stride=2 (mono)
-code 16tap-upsample ( 'out 'in /in 'weights #phases -- )
+d# 16 constant taps/phase
+
+code 16tap-upsample ( 'out 'in /in 'weights #phases -- 'out' )
ldmia sp!,{r0,r1,r2,r3} \ r0:'weights r1:/in r2:'in r3:'out tos:#phases
mov r4,#15 \ Multiplier scale factor
@@ -88,7 +90,7 @@
decs r1,#2 \ Decrement input length by the sample size
0<= until
- pop tos,sp
+ mov tos,r3
c;
\ Filter coefficients for 6x upsampling. The following filter was
@@ -152,9 +154,19 @@
end
[then]
+taps/phase 2+ 2* /w* constant /end-buf
+/end-buf buffer: end-buf
+
: upsample6 ( src-adr /src dst-adr -- )
- enable-iwmmx ( src-adr #src-samples dst-adr )
- -rot weights-6phase #phases 16tap-upsample ( )
+ enable-iwmmx ( src-adr /src dst-adr )
+ >r taps/phase /w* - ( src-adr /src' r: dst-adr )
+ r> third third ( src-adr /src dst-adr src-adr /src )
+ weights-6phase #phases 16tap-upsample ( src-adr /src dst-adr' )
+ -rot + ( dst-adr src-adr' )
+ end-buf /end-buf erase ( dst-adr src-adr' )
+ end-buf taps/phase /w* move ( dst-adr )
+ end-buf taps/phase /w* weights-6phase #phases 16tap-upsample ( dst-adr' )
+ drop
;
\ LICENSE_BEGIN
Modified: cpu/arm/olpc/1.75/alc5631.fth
==============================================================================
--- cpu/arm/olpc/1.75/alc5631.fth Wed Oct 12 23:27:50 2011 (r2597)
+++ cpu/arm/olpc/1.75/alc5631.fth Wed Oct 12 23:49:29 2011 (r2598)
@@ -1,12 +1,6 @@
\ See license at end of file
purpose: Driver for Realtek ALC5631Q audio CODEC chip
-: adc-on ( -- ) h# 0c00 h# 3a codec-set ;
-: adc-off ( -- ) h# 0c00 h# 3a codec-clr ;
-: dac-on ( -- ) h# 0300 h# 3a codec-set ;
-: dac-off ( -- ) h# 0300 h# 3a codec-clr ;
-: adc+dac-on ( -- ) h# 0f00 h# 3a codec-set ;
-
: set-routing ( -- )
h# c0c0 h# 02 codec-set \ SPKMIXLR -> SPKVOLLR, muted
h# c0c0 h# 04 codec-set \ OUTMIXLR -> HPOVOLLR, muted
@@ -45,14 +39,6 @@
h# 1010 h# 38 codec! \ Divisors; the values in this register don't seem to make much
\ difference unless you set the divisors to very high values.
;
-: elided ( -- )
- \ The ADC and DAC will be turned on as needed by adc-on and dac-on, after
- \ the BCLK clock from the SoC is on. If you turn on the ADC when BCLK is
- \ not clocking, the ADC often doesn't output any data.
- b# 1001.0000.1110.0000 h# 3a codec! \ All on except ADC and DAC
- b# 1111.1100.0011.1100 h# 3b codec! \ All on except PLL
- b# 1111.1100.0000.0000 h# 3e codec! \ AXI and MONO IN off
-;
: mic-bias-off ( -- ) h# 000c h# 3b codec-clr ;
: mic-bias-on ( -- ) h# 000c h# 3b codec-set ;
@@ -176,11 +162,13 @@
\ h# 0000 pwr3b! \ Power off PLL
;
: open-out-specific ( -- )
+ \ Turning on the DAC here at the beginning seems to prevent pops better than doing
+ \ it a few steps later at the point that Realtek suggested.
+ h# 0300 h# 3a codec-set \ Power on DACs
h# 0060 h# 3a codec-set \ Power on DAC to mixer
speakers-on? if h# 1000 h# 3a codec-set then \ Power on ClassD amp
speakers-on? if h# c000 h# 3e codec-set then \ Power on SPKL/RVOL
headphones-on? if h# 0c00 h# 3e codec-set then \ Power on HPOVOLL/R
-\ h# 0300 h# 3a codec-set \ Power on DACL/R - defer until dac-on is called by start-audio-out or out-in
h# c000 pwr3b! \ Power on OUTMIXL/R
speakers-on? if h# 3000 h# 3b codec-set then \ Power on SPKMIXL/R
@@ -192,7 +180,7 @@
open-common
open-out-specific
;
-
+
: close-out-specific ( -- )
speakers-on? if mute-speakers then
headphones-on? if hp-powerdown-depop then
@@ -218,7 +206,7 @@
adc-stereo
h# 0c00 h# 3b codec-set \ Power on RECMIXLR
h# 0030 h# 3b codec-set \ Power on MIC1/2 boost gain
-\ h# 0c00 h# 3a codec-set \ Power on ADCL/R - defer until adc-on is called by audio-in or out-in
+ h# 0c00 h# 3a codec-set \ Power on ADCL/R
;
: open-in ( -- )
\ h# 46f0 h# 44 codec! \ pll: 256000 -> 2048000 ??? why is this different from playback? - 8khz record?
Modified: cpu/arm/olpc/1.75/sound.fth
==============================================================================
--- cpu/arm/olpc/1.75/sound.fth Wed Oct 12 23:27:50 2011 (r2597)
+++ cpu/arm/olpc/1.75/sound.fth Wed Oct 12 23:49:29 2011 (r2598)
@@ -345,7 +345,6 @@
out-len if copy-out then \ Prefill the second buffer
start-out-ring
master-tx
- dac-on
install-playback-alarm
true to playing?
;
@@ -390,7 +389,6 @@
make-in-ring ( actual )
start-in-ring ( actual )
master-rx ( actual )
- adc-on ( actual )
begin in-len while ( actual )
wait-in ( actual )
copy-in ( actual )
@@ -436,8 +434,6 @@
master-rx ( ) \ Now the clock is on
slave-tx ( )
- adc+dac-on ( )
-
true to playing?
begin in-len playing? or while ( )
@@ -453,11 +449,8 @@
reset-rx
reset-tx
- dac-off adc-off ( )
-
- mono? if collapse-in then ( )
-
close-out-in
+ mono? if collapse-in then ( )
;
0 [if] \ Interactive test words for out-in
Author: quozl
Date: Wed Oct 12 23:27:50 2011
New Revision: 2597
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2597
Log:
Q3B20
(note that this version was not svn head at this point, but rather svn
2318 with 2589)
Modified:
cpu/x86/pc/olpc/via/ec-version.fth
cpu/x86/pc/olpc/via/fw-version.fth
Modified: cpu/x86/pc/olpc/via/ec-version.fth
==============================================================================
--- cpu/x86/pc/olpc/via/ec-version.fth Wed Oct 12 20:49:37 2011 (r2596)
+++ cpu/x86/pc/olpc/via/ec-version.fth Wed Oct 12 23:27:50 2011 (r2597)
@@ -1,5 +1,5 @@
\ The EC microcode
-macro: EC_VERSION 2_2_8
+macro: EC_VERSION 2_2_9
\ Alternate command for getting EC microcode, for testing new versions.
\ Temporarily uncomment the line and modify the path as necessary
Modified: cpu/x86/pc/olpc/via/fw-version.fth
==============================================================================
--- cpu/x86/pc/olpc/via/fw-version.fth Wed Oct 12 20:49:37 2011 (r2596)
+++ cpu/x86/pc/olpc/via/fw-version.fth Wed Oct 12 23:27:50 2011 (r2597)
@@ -1,3 +1,3 @@
\ The overall firmware revision
macro: FW_MAJOR B
-macro: FW_MINOR 19
+macro: FW_MINOR 20
Author: quozl
Date: Wed Oct 12 02:48:03 2011
New Revision: 2594
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2594
Log:
Q2E47
(note that this version was not svn head at this point, but rather svn
2393 with svn 2585 and 2589)
Modified:
cpu/x86/pc/olpc/versions.fth
Modified: cpu/x86/pc/olpc/versions.fth
==============================================================================
--- cpu/x86/pc/olpc/versions.fth Wed Oct 12 02:30:09 2011 (r2593)
+++ cpu/x86/pc/olpc/versions.fth Wed Oct 12 02:48:03 2011 (r2594)
@@ -2,7 +2,7 @@
\ The overall firmware revision
macro: FW_MAJOR E
-macro: FW_MINOR 46
+macro: FW_MINOR 47
\ The EC microcode
macro: EC_VERSION e35