mail.coreboot.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
List overview
Download
openfirmware
January 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
openfirmware@openfirmware.info
4 participants
65 discussions
Start a n
N
ew thread
[commit] r2109 - dev/mmc/sdhci
by repository service
17 Jan '11
17 Jan '11
Author: wmb Date: Mon Jan 17 07:20:26 2011 New Revision: 2109 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2109
Log: sdhci.fth - added definition of le-l@ for the fcode-building case. Modified: dev/mmc/sdhci/sdhci.fth Modified: dev/mmc/sdhci/sdhci.fth ============================================================================== --- dev/mmc/sdhci/sdhci.fth Fri Jan 14 01:10:40 2011 (r2108) +++ dev/mmc/sdhci/sdhci.fth Mon Jan 17 07:20:26 2011 (r2109) @@ -1141,6 +1141,12 @@ r> base ! ; +[ifndef] le-l@ +: le-l@ ( adr -- l ) + >r r@ c@ r@ 1+ c@ r@ 2+ c@ r> 3 + c@ bljoin +; +[then] + \ The calculation below is shown on page 81 of the \ SD Physical Layer Simplified Specification Version 2.00. : size ( -- d.bytes )
1
0
0
0
[commit] r2108 - cpu/arm
by repository service
14 Jan '11
14 Jan '11
Author: wmb Date: Fri Jan 14 01:10:40 2011 New Revision: 2108 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2108
Log: ARM assembler enhancements and bug fixes, thanks to Mike Tuciarone. Modified: cpu/arm/assem.fth Modified: cpu/arm/assem.fth ============================================================================== --- cpu/arm/assem.fth Sat Jan 8 11:23:43 2011 (r2107) +++ cpu/arm/assem.fth Fri Jan 14 01:10:40 2011 (r2108) @@ -548,16 +548,18 @@ : amode-rdop2 ( -- ) init-operands get-r12 get-opr2 !op ; : amode-rev ( -- ) init-operands get-r12 get-r00 !op ; -: amode-lsm ( -- ) +: amode-lsm ( need-r16? -- ) init-operands - get-r16 ( ) - adr-delim ascii ! = if ( ) - flip-w ( ) - require-field " ," ?expecting drop ( ) - then ( ) + if + get-r16 ( ) + adr-delim ascii ! = if ( ) + flip-w ( ) + require-field " ," ?expecting drop ( ) + then ( ) - \ There should be a comma on the end of the register. - adr-delim ascii , <> " ," ?expecting + \ There should be a comma on the end of the register. + adr-delim ascii , <> " ," ?expecting + then \ The next thing up should be an open brace for the register list. get-whatever adt-delimiter <> " {" ?expecting @@ -583,7 +585,6 @@ \ We've finished the register list, is there a ^ hanging on the end? ascii ^ parse-1 if flip-b then - !op ; @@ -713,6 +714,9 @@ : amode-swp ( -- ) init-operands get-r12 get-r00 ['] get-off0 get-ea !op ; +: amode-ldrex ( -- ) + init-operands get-r12 ['] get-off0 get-ea !op +; : amode-copr ( -- ) \ Co-processors: mcr, mrc \ p, #, r, c, c, # @@ -769,6 +773,9 @@ \ This word looks for [|b] on swp commands. : {b} ( -- ) ascii b parse-1 if flip-b then ; +\ This word looks for [|bh] on ld/strex commands. +: {bh} ( -- ) ascii h parse-1 if flip-b flip-w else {b} then ; + \ If the s flag is found, set bit 20 for alu commmands. : {s} ( -- ) ascii s parse-1 if 0010.0000 iop then ; @@ -913,6 +920,7 @@ : orr 0180.0000 {cond/s} amode-rrop2 ; : bic 01c0.0000 {cond/s} amode-rrop2 ; +: clz 016f.0f10 {cond/s} amode-rdop2 ; : mov 01a0.0000 {cond/s} amode-rdop2 ; : mvn 01e0.0000 {cond/s} amode-rdop2 ; @@ -944,10 +952,14 @@ : bx 012f.ff10 {cond} amode-bx ; -: swp 0100.0090 {cond} {b} amode-swp ; - -: ldm 0810.0000 {cond} 1 parse-inc amode-lsm ; -: stm 0800.0000 {cond} 0 parse-inc amode-lsm ; +: swp 0100.0090 {cond} {b} amode-swp ; +: strex 0180.0f90 {cond} {bh} amode-swp ; +: ldrex 0190.0f9f {cond} {bh} amode-ldrex ; + +: ldm 0810.0000 {cond} 1 parse-inc 1 amode-lsm ; +: popm 08bd.0000 {cond} 0 amode-lsm ; +: stm 0800.0000 {cond} 0 parse-inc 1 amode-lsm ; +: pushm 092d.0000 {cond} 0 amode-lsm ; : ldr ( -- ) 0410.0000 {cond} {shbt} ; : str ( -- ) 0400.0000 {cond} {hbt} ; @@ -959,33 +971,42 @@ : rd-field ( reg# -- ) d# 12 set-field ; : rb-field ( reg# -- ) d# 16 set-field ; -\ XXX need ADR, SET \ adr{cond} rN,<address> +\ set{cond} rN,<imm> +: asm-const ( const adr? -- op ) + ea00.0000 asm, \ b here+8 + if here asm-set-relocation-bit drop then + asm, \ const + 051f.000c \ ldr rN,[pc,#-12] +; : (set) ( address? -- ) >r 0000.0000 {cond} init-operands \ Put the register number on the return stack so it won't interfere \ with the stack items used by any "*" operands there may be. get-register >r ( r: adr? reg# ) - get-immediate ( address r: adr? reg# ) - dup here >offset ( address offset r: adr? reg# ) - dup fits? if ( address offset r: adr? reg# ) - nip nip 028f.0000 ( op r: adr? reg# ) \ add rN,pc,#<offset> - else ( address offset r: adr? reg# ) - negate fits? if ( address r: adr? reg# ) - drop 024f.0000 ( op r: adr? reg# ) \ sub rN,pc,#<offset> - else ( address r: adr? reg# ) - ea00.0000 asm, ( address r: adr? reg# ) \ b here+8 - r> r@ swap >r if ( address r: adr? reg# ) - here asm-set-relocation-bit drop + get-immediate r> r> rot ( reg# adr? addr|imm ) + 2dup swap if ( reg# adr? addr|imm addr|imm ) + here >offset ( reg# adr? addr|imm offset|imm ) + then + dup fits? if ( reg# adr? addr|imm offset|imm ) + 2drop if + 028f.0000 ( reg# op ) \ add rN,pc,#<offset> + else + 03a0.0000 ( reg# op ) \ mov rN,#<imm> + then + else ( reg# adr? addr|imm offset|imm ) + rot if ( reg# addr offset ) + negate fits? if ( reg# addr ) + drop 024f.0000 ( reg# op ) \ sub rN,pc,#<offset> + else ( reg# addr ) + true asm-const ( reg# op ) then - asm, ( r: adr? reg# ) \ adr - 051f.000c ( op r: adr? reg# ) \ ldr rN,[pc,#-12] - then ( op r: adr? reg# ) - then ( op r: adr? reg# ) - iop r> rd-field ( ) - r> drop - !op + else ( reg# imm imm ) + drop false asm-const ( reg# op ) + then ( reg# op ) + then ( reg# op ) + iop rd-field !op ; : adr ( -- ) true (set) ; : set ( -- ) false (set) ; @@ -1000,6 +1021,9 @@ : sev ( -- ) h# 0320f004 {cond} !op ; : nop ( -- ) h# e1a00000 asm, ; \ mov r0,r0 +: dsb ( -- ) h# f57ff040 asm, ; +: dmb ( -- ) h# f57ff050 asm, ; +: isb ( -- ) h# f57ff060 asm, ; : # ( -- adt-immed ) adt-immed ; : reg ( -- adt-reg ) adt-reg ;
1
0
0
0
Changing default graphics port on a Powermac g4 quicksilver
by Super Bisquit
12 Jan '11
12 Jan '11
My machine does not have the diagnostics installed. How do I change the default from agp to one of the pci slots?
1
0
0
0
[commit] r2107 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 11:23:43 2011 New Revision: 2107 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2107
Log: Q4A10d Modified: cpu/arm/olpc/1.75/fw-version.fth Modified: cpu/arm/olpc/1.75/fw-version.fth ============================================================================== --- cpu/arm/olpc/1.75/fw-version.fth Sat Jan 8 11:16:58 2011 (r2106) +++ cpu/arm/olpc/1.75/fw-version.fth Sat Jan 8 11:23:43 2011 (r2107) @@ -1,3 +1,3 @@ \ The overall firmware revision macro: FW_MAJOR A -macro: FW_MINOR 10 +macro: FW_MINOR 10d
1
0
0
0
[commit] r2106 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 11:16:58 2011 New Revision: 2106 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2106
Log: OLPC XO-1.75 A2 - Made compass driver work and tweaked on accelerometer driver. Modified: cpu/arm/olpc/1.75/compass.fth Modified: cpu/arm/olpc/1.75/compass.fth ============================================================================== --- cpu/arm/olpc/1.75/compass.fth Sat Jan 8 11:15:54 2011 (r2105) +++ cpu/arm/olpc/1.75/compass.fth Sat Jan 8 11:16:58 2011 (r2106) @@ -5,6 +5,7 @@ 4 to smb-clock-gpio# 5 to smb-data-gpio# h# 3c to smb-slave + 5 smb-data-gpio# gpio-dir-out ; : smb-init ( -- ) set-compass-slave smb-on smb-pulses ; @@ -12,31 +13,48 @@ : compass! ( byte reg# -- ) set-compass-slave smb-byte! ; : open ( -- okay? ) 0 0 ['] compass! catch if false exit then - h# a compass@ [char] H <> + h# a compass@ [char] H = if + 0 2 compass! \ Continuous conversion mode + true + else + false + then ; : close ( -- ) + 2 2 compass! \ Idle mode +; +: dir@ ( reg# -- n ) + dup compass@ swap 1+ compass@ swap bwjoin wextend +; +: direction@ ( -- x y z ) + begin 9 compass@ 1 and until + 3 dir@ 5 dir@ 7 dir@ ( x y z ) ; -\ XXX need some words to take compass readings - end-package 0 0 " " " /" begin-package " combo-accelerometer" name -: set-sensor-slave ( -- ) h# 30 6 set-twsi-target ; -: sensor@ ( reg# -- byte ) set-sensor-slave twsi-b@ ; -: sensor! ( byte reg# -- ) set-sensor-slave twsi-b@ ; +\ : set-sensor-slave ( -- ) h# 30 6 set-twsi-target ; +: set-sensor-slave ( -- ) + 4 to smb-clock-gpio# + 5 to smb-data-gpio# + h# 30 to smb-slave + 5 smb-data-gpio# gpio-dir-out +; + +: sensor@ ( reg# -- byte ) set-sensor-slave smb-byte@ ; +: sensor! ( byte reg# -- ) set-sensor-slave smb-byte@ ; : accelerometer-on ( -- ) h# 27 h# 20 sensor! ; : accelerometer-off ( -- ) h# 07 h# 20 sensor! ; -: wext ( w -- l ) dup h# 8000 and if h# ffff0000 or then ; : acceleration@ ( -- x y z ) set-sensor-slave - h# 28 1 6 twsi-get ( xl xh yl yh zl zh ) + 6 h# 28 smb-read-n ( xl xh yl yh zl zh ) 2>r 2>r ( xl xh ) - bwjoin wext ( x r: zl,zh yl,yh ) - 2r> bwjoin wext ( x y r: zl,zh ) - 2r> bwjoin wext ( x y z ) + bwjoin wextend ( x r: zl,zh yl,yh ) + 2r> bwjoin wextend ( x y r: zl,zh ) + 2r> bwjoin wextend ( x y z ) ; : open ( -- okay? )
1
0
0
0
[commit] r2105 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 11:15:54 2011 New Revision: 2105 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2105
Log: OLPC XO-1.75 A2 - Added support for switching between internal MicroSD and eMMC. Added: cpu/arm/olpc/1.75/emmc.fth Modified: cpu/arm/olpc/1.75/devices.fth Modified: cpu/arm/olpc/1.75/devices.fth ============================================================================== --- cpu/arm/olpc/1.75/devices.fth Sat Jan 8 11:12:51 2011 (r2104) +++ cpu/arm/olpc/1.75/devices.fth Sat Jan 8 11:15:54 2011 (r2105) @@ -223,6 +223,9 @@ ' 15x30pc to romfont fload ${BP}/cpu/arm/olpc/1.75/sdhci.fth +[ifndef] cl2-a1 +fload ${BP}/cpu/arm/olpc/1.75/emmc.fth +[then] devalias int /sd/disk@3 devalias ext /sd/disk@1 @@ -319,9 +322,11 @@ ec-api-ver@ " ec-version" integer-property [then] +[ifndef] cl2-a2 \ XXX remove this ifndef when the new EC code is ready ['] ec-name$ catch 0= if " ec-name" string-property then ['] ec-date$ catch 0= if " ec-date" string-property then ['] ec-user$ catch 0= if " ec-user" string-property then +[then] dend " /openprom" find-device Added: cpu/arm/olpc/1.75/emmc.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/emmc.fth Sat Jan 8 11:15:54 2011 (r2105) @@ -0,0 +1,55 @@ +\ XXX do we need to set the internal SD for fast drive in boardgpio.fth ? +: select-internal-sd ( -- ) + ." Using internal SD" cr + h# d8c3 d# 113 af! \ SD_CMD + h# d8c3 d# 126 af! \ SD_DATA2 + h# d8c3 d# 127 af! \ SD_DATA0 + h# d8c3 d# 130 af! \ SD_DATA3 + h# d8c3 d# 135 af! \ SD_DATA1 + h# d8c3 d# 138 af! \ SD_CLK + h# c1 d# 111 af! \ eMMC_D0 as GPIO + h# c1 d# 112 af! \ eMMC_CMD as GPIO + h# c1 d# 151 af! \ eMMC_CLK as GPIO + h# c1 d# 162 af! \ eMMC_D6 as GPIO + h# c1 d# 163 af! \ eMMC_D4 as GPIO + h# c1 d# 164 af! \ eMMC_D2 as GPIO + h# c1 d# 165 af! \ eMMC_D7 as GPIO + h# c1 d# 166 af! \ eMMC_D5 as GPIO + h# c1 d# 167 af! \ eMMC_D3 as GPIO + h# c1 d# 168 af! \ eMMC_D1 as GPIO +; +: select-emmc ( -- ) + ." Using eMMC" cr + h# c1 d# 113 af! \ SD_CMD as GPIO + h# c1 d# 126 af! \ SD_DATA2 as GPIO + h# c0 d# 127 af! \ SD_DATA0 as GPIO + h# c0 d# 130 af! \ SD_DATA3 as GPIO + h# c0 d# 135 af! \ SD_DATA1 as GPIO + h# c0 d# 138 af! \ SD_CLK as GPIO + + \ XXX perhaps 18c2 for fast? + h# c2 d# 111 af! \ eMMC_D0 + h# c2 d# 112 af! \ eMMC_CMD + h# c2 d# 151 af! \ eMMC_CLK + h# c2 d# 162 af! \ eMMC_D6 + h# c2 d# 163 af! \ eMMC_D4 + h# c2 d# 164 af! \ eMMC_D2 + h# c2 d# 165 af! \ eMMC_D7 + h# c2 d# 166 af! \ eMMC_D5 + h# c2 d# 167 af! \ eMMC_D3 + h# c2 d# 168 af! \ eMMC_D1 + + d# 149 gpio-set \ Release eMMC_RST# + + d# 34 gpio-set \ This is for the case where the eMMC power is rewired to the WLAN +; +\ Says COMM - is RST# +\ Says RESET - is CMD + +stand-init: + d# 56 gpio-pin@ if + select-emmc + else + select-internal-sd + then +;
1
0
0
0
[commit] r2104 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 11:12:51 2011 New Revision: 2104 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2104
Log: OLPC XO-1.75 A2 - fixed some errors in the pin muxing for A2. Modified: cpu/arm/olpc/1.75/boardgpio.fth Modified: cpu/arm/olpc/1.75/boardgpio.fth ============================================================================== --- cpu/arm/olpc/1.75/boardgpio.fth Sat Jan 8 11:11:59 2011 (r2103) +++ cpu/arm/olpc/1.75/boardgpio.fth Sat Jan 8 11:12:51 2011 (r2104) @@ -5,6 +5,7 @@ d# 01 gpio-dir-out \ EN_USB_PWR d# 04 gpio-dir-out \ COMPASS_SCL + d# 05 gpio-dir-out \ COMPASS_SDA d# 08 gpio-dir-out \ AUDIO_RESET# d# 10 gpio-dir-out \ LED_STORAGE d# 11 gpio-dir-out \ VID2 @@ -16,10 +17,10 @@ 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 [ifdef] cl2-a1 + d# 97 gpio-dir-out \ RTC_SCK + d# 98 gpio-dir-out \ RTC_SDA [else] d# 53 gpio-set \ RTC_SCK d# 53 gpio-dir-out \ RTC_SCK @@ -313,10 +314,10 @@ 2 af, \ GPIO_162 - eMMC_D6 2 af, \ GPIO_163 - eMMC_D4 2 af, \ GPIO_164 - eMMC_D2 - 1 af, \ GPIO_165 - eMMC_D7 - 1 af, \ GPIO_166 - eMMC_D5 - 1 af, \ GPIO_167 - eMMC_D3 - 1 af, \ GPIO_168 - eMMC_D1 + 2 af, \ GPIO_165 - eMMC_D7 + 2 af, \ GPIO_166 - eMMC_D5 + 2 af, \ GPIO_167 - eMMC_D3 + 2 af, \ GPIO_168 - eMMC_D1 [then] : init-mfprs
1
0
0
0
[commit] r2103 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 11:11:59 2011 New Revision: 2103 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2103
Log: OLPC XO-1.75 - Moved the codec-specific words from the sound driver into separate files for each of the two codec choices. Added: cpu/arm/olpc/1.75/alc5624.fth cpu/arm/olpc/1.75/alc5631.fth Modified: cpu/arm/olpc/1.75/sound.fth Added: cpu/arm/olpc/1.75/alc5624.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/alc5624.fth Sat Jan 8 11:11:59 2011 (r2103) @@ -0,0 +1,194 @@ +\ See license at end of file +purpose: Driver for Realtek ALC5624 audio CODEC chip + +: codec-bias-off ( -- ) + h# 8080 h# 02 codec-set + h# 8080 h# 04 codec-set + h# 0000 h# 3a codec! + h# 0000 h# 3c codec! + h# 0000 h# 3e codec! +; +: linux-codec-on + h# 0000 h# 26 codec! \ Don't power down any groups + h# 8000 h# 5e codec! \ Disable fast vref + h# 0c00 h# 3e codec! \ enable HP out volume power + h# 0002 h# 3a codec! \ enable Main bias + h# 2000 h# 3c codec! \ enable Vref + h# 6808 h# 0c codec! \ Stereo DAC Volume + h# 3f3f h# 14 codec! \ ADC Record Mixer Control + h# 4b40 h# 1c codec! \ Output Mixer Control + h# 0500 h# 22 codec! \ Microphone Control + h# 04e8 h# 40 codec! \ General Purpose Control +; +: codec-on ( -- ) + h# 0000 h# 26 codec! \ Don't power down any groups + h# 8002 h# 34 codec! \ Slave mode, 16 bits, left justified + b# 1000.1000.0011.1111 h# 3a codec! \ All on except MONO depop, 0-cross + b# 1010.0011.1111.0011 h# 3c codec! \ All on except ClassAB, PLL, speaker mixer, MONO mixer + b# 0011.1111.1100.1111 h# 3e codec! \ All on except MONO_OUT and PHONE in + h# 0140 h# 40 codec! \ MCLK is SYSCLK, HPamp Vmid 1.25, ClassDamp Vmid 1.5 +; +: codec-off ( -- ) + h# ef00 h# 26 codec! \ Power down everything +; +\ Mic bias 2 is for external mic +: mic-gain ( bits11:8 -- ) h# f00 h# 22 codec-field ; +: mic+0db ( -- ) 0 mic-gain ; \ Needed +: mic+20db ( -- ) h# 500 mic-gain ; \ Needed +: mic+30db ( -- ) h# a00 mic-gain ; +: mic+40db ( -- ) h# f00 mic-gain ; + +: mic-bias-off ( -- ) h# 000c h# 3a codec-clr ; +: mic-bias-on ( -- ) h# 000c h# 3a codec-set ; + +: mic1-high-bias ( -- ) h# 20 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic1-low-bias ( -- ) h# 20 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V +: mic2-high-bias ( -- ) h# 10 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic2-low-bias ( -- ) h# 21 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V + +\ The mic bias short circuit detection threshold can be set with reg 0x22 bits 1:0 - +\ 00:600uA 01:1200uA 1x:1800uA +\ 600uA is probably good for OLPC, since the 5.6K bias resistor limits the SC current to less than that. + +\ Sets both speakers simultaneously +: speakers-source ( value -- ) h# d800 h# 1c codec-field ; + +: speakers-off ( -- ) 0 speakers-source ; +: hp-mixer>speakers ( -- ) h# 4800 speakers-source ; +: speaker-mixer>speakers ( -- ) h# 9000 speakers-source ; +: mono>speakers ( -- ) h# d800 speakers-source ; + +: class-ab-speakers ( -- ) h# 2000 h# 1c codec-clr ; +: class-d-speakers ( -- ) h# 2000 h# 1c codec-set ; + +: headphones-off ( -- ) h# 300 h# 1c codec-clr ; +: headphones-on ( -- ) h# 300 h# 1c codec-set ; + +0 [if] \ OLPC does not connect the MONO output +: mono-source ( value -- ) h# c0 h# 1c codec-field ; +: mono-off ( -- ) 0 mono-source ; +: hp-mixer>mono ( -- ) h# 40 mono-source ; +: speaker-mixer>mono ( -- ) h# 80 mono-source ; +: mono-mixer>mono ( -- ) h# c0 mono-source ; +[then] + +: headphones-inserted? ( -- flag ) h# 54 codec@ 2 and 0<> ; + +\ The range is from -34.5 db to +12 dB +: gain>lr ( db -- true | regval false ) + 2* 3 / ( steps ) \ Converts -34.5 .. 12 db to -23 .. 8 steps + dup d# -23 < if ( steps ) + drop true + else ( steps ) + 8 swap - ( -steps ) + 0 max ( clipped-steps ) + dup 8 lshift or ( regval ) + false + then +; +\ The range is from -46.5 db to 0 dB +: >output-volume ( db -- regval mask ) + d# 12 + \ Bias to the range used by gain>lr + gain>lr if h# 8080 then h# 9f9f +; +: set-speaker-volume ( n -- ) >output-volume 2 codec-field ; +: set-headphone-volume ( n -- ) >output-volume 4 codec-field ; +\ : set-mono-volume ( n -- ) >output-volume 6 codec-field ; +: set-volume ( n -- ) + dup set-speaker-volume set-headphone-volume +; +d# 0 constant default-adc-gain \ 0 dB - range is -16.5 to +30 +d# 0 constant default-dac-gain \ 0 dB - range is -34.5 to +12 +d# 44 constant default-mic-gain \ 44 dB - range is -34.5 to +d# 0 constant default-speaker-volume \ 0 dB - range is -46.5 to 0 +d# 0 constant default-headphone-volume \ 0 dB - range is -46.5 to 0 + +: select-headphones ( -- ) h# 300 h# 1c codec! ; +: select-speakers-ab ( -- ) h# 4800 h# 1c codec! ; \ ClassAB, headphone mixer +: select-speakers ( -- ) h# 6800 h# 1c codec! ; \ ClassD, headphone mixer + +: set-line-in-gain ( n -- ) + gain>lr if h# e000 then h# ff1f h# 0a codec-field +; +: set-dac-gain ( n -- ) + gain>lr if h# e000 then h# ff1f h# 0c codec-field +; +false value external-mic? +: mic-routing ( -- n ) + \ Mute selected MIC inputs to the ADC as follows: + \ For external, we send MIC1 to left and MIC2 to right + \ For internal, we send MIC1 to both left and right + external-mic? if h# 2040 else h# 2020 then +; +: set-mic-boost ( db -- db' ) + dup d# 26 > if mic+40db d# 40 - exit then + dup d# 16 > if mic+30db d# 30 - exit then + dup d# 06 > if mic+20db d# 20 - exit then + mic+0db +; +: set-mic-gain ( db -- ) + set-mic-boost ( db' ) + gain>lr if ( ) \ Mute + \ Turn everything off + mic-bias-off ( ) + 0 h# 6060 h# e0e0 ( gain adc-mute mic-output-mute ) + else ( gain ) + mic-bias-on ( gain ) + \ Mic routing to ADC depends on internal or external mic + mic-routing ( gain adc-mute ) + \ To avoid feedback, we do not feedthrough the mic + h# e0e0 ( gain adc-mute mic-output-mute ) + then ( gain adc-mute mic-output-mute ) + h# e0e0 h# 10 codec-field ( gain adc-mute ) + h# 6060 h# 14 codec-field ( gain ) + h# 1f1f h# 0e codec-field +; +: set-adc-gain ( db -- ) \ Range is -16.5 dB to +30 dB + d# 18 - ( db' ) + gain>lr if 0 then ( gain ) + h# f9f h# 12 codec-field + h# 60 h# 12 codec-set \ Enable ADC zero-cross detectors +; +: set-default-gains ( -- ) + headphones-inserted? if select-headphones else select-speakers then + default-speaker-volume set-speaker-volume + default-headphone-volume set-headphone-volume + default-dac-gain set-dac-gain + default-mic-gain set-mic-gain + default-adc-gain set-adc-gain +; + +: set-codec-sample-rate ( rate -- ) + case + d# 8000 of h# 2222 h# 5272 endof + d# 16000 of h# 2020 h# 2272 endof + d# 32000 of h# 2121 h# 2172 endof + d# 48000 of h# 0000 h# 3072 endof + ( default ) true abort" Unsupported audio sample rate" + endcase ( reg62val2 reg60val ) + h# 60 codec! h# 62 codec! +; + +\ LICENSE_BEGIN +\ Copyright (c) 2011 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 Added: cpu/arm/olpc/1.75/alc5631.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/alc5631.fth Sat Jan 8 11:11:59 2011 (r2103) @@ -0,0 +1,200 @@ +\ See license at end of file +purpose: Driver for Realtek ALC5631Q audio CODEC chip + +: codec-on ( -- ) + h# 8001 h# 34 codec! \ Slave mode, 16 bits, left justified + b# 1001.1111.1110.0000 h# 3a codec! \ All on + b# 1111.1100.0011.1100 h# 3b codec! \ All on except PLL + b# 1010.0000.0001.1101 h# 3c codec! \ All on except AX and MONO + b# 1111.1100.0000.0000 h# 3e codec! \ AXI and MONO IN off +\ h# 8c00 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, use HPFs + h# 8000 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, no HPFs + h# 0000 h# 42 codec! \ Use MCLK, not PLL + b# 1110.1100.1001.0000 h# 52 codec! \ Protection on + h# 4000 h# 56 codec! \ Power on Cap-free block with de-pop +; +: codec-off ( -- ) + 0 h# 3a codec! \ All off + 0 h# 3b codec! \ All off + 0 h# 3c codec! \ All off + 0 h# 3e codec! \ All off +; +: mic-bias-off ( -- ) h# 000c h# 3b codec-clr ; +: mic-bias-on ( -- ) h# 000c h# 3b codec-set ; + +: mic1-high-bias ( -- ) h# 80 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic1-low-bias ( -- ) h# 80 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V +: mic2-high-bias ( -- ) h# 08 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic2-low-bias ( -- ) h# 08 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V + +\ The range is from -46.5 db to +12 dB +: gain>lr-12 ( db -- true | regval false ) + d# 12 min ( db' ) + 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps + dup d# -31 < if ( steps ) + drop true + else ( steps ) + 8 swap - ( -steps ) + 0 max ( clipped-steps ) + dup 8 lshift or ( regval ) + false + then +; +\ The range is from -46.5 db to 0 dB +: gain>lr ( db -- true | regval false ) + 0 min ( db' ) + 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps + dup d# -31 < if ( steps ) + drop true + else ( steps ) + 0 swap - ( -steps ) + 0 max ( clipped-steps ) + dup 8 lshift or ( regval ) + false + then +; + +\ This sets up a simple routing from the DAC to the headphone and speaker outputs +: output-config ( -- ) + h# df00 h# 1a codec! \ DACL -> OUTMIXL + h# df00 h# 1c codec! \ DACR -> OUTMIXR + h# 4040 h# 04 codec-set \ OUTMIXLR -> HPOVOLLR + h# d0d0 h# 28 codec! \ DACLR -> SPKMIXLR + h# 4040 h# 02 codec-set \ SPKMIXLR -> SPKVOLLR + h# 9000 h# 2a codec! \ SPKVOLL -> SPOLMIX, SPKVOLR -> SPORMIX + h# 0000 h# 2c codec! \ SPOxMIX -> SPKRMUX, HPOVOL -> HPMUX +; + +: mute-speakers ( -- ) h# 8080 2 codec-set ; +: set-speaker-volume ( n -- ) \ DONE + gain>lr-12 if h# 8080 then h# bfbf 2 codec-field +; +: mute-headphones ( -- ) h# 8080 4 codec-set ; +: set-headphone-volume ( n -- ) \ DONE + gain>lr if h# 8080 then h# 9f9f 4 codec-field +; +: set-volume ( n -- ) + headphones-inserted? if + set-headphone-volume + else + set-speaker-volume + then +; +d# 0 constant default-adc-gain \ 0 dB - range is -96.625 to +28.5 +d# 0 constant default-dac-gain \ 0 dB - range is -96.625 to +28.5 +d# 44 constant default-mic-gain \ 44 dB - range is 0 to 50 dB +d# 0 constant default-speaker-volume \ 0 dB - range is -46.5 to +12 +d# -10 constant default-headphone-volume \ -10 dB - range is -46.5 to 0 + +: adc-mute-all ( -- ) h# f0f0 h# 14 codec! ; +: adc-mute-mic ( -- ) h# 4040 h# 14 codec-set ; +: adc-unmute-mic ( -- ) h# 4040 h# 14 codec-clr ; +\ : adc-unmute-outmix ( -- ) h# 8080 h# 14 codec-clr ; + +\ The useful one is outmix-unmute-dac +: outmix-mute-all ( -- ) h# ff00 dup h# 1a codec! h# 1c codec! ; +: outmix-mute-mic ( -- ) h# 1000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-mic ( -- ) h# 1000 dup h# 1a codec-clr h# 1c codec-clr ; +: outmix-mute-dac ( -- ) h# 2000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-dac ( -- ) h# 2000 dup h# 1a codec-clr h# 1c codec-clr ; +: outmix-mute-recmix ( -- ) h# 8000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-recmix ( -- ) h# 8000 dup h# 1a codec-clr h# 1c codec-clr ; + +: gain>lr-3/8 ( -- lrgain boost ) + d# 28 min + dup 0>= if ( n ) + 8 3 */ ( boost ) \ Convert to .375 dB increments + 0 swap ( lrgain boost ) + else ( n ) + dup d# -96 <= if ( n ) + drop ( ) + h# ffff h# 8080 ( lrgain boost ) + else ( n ) + negate 8 3 */ ( steps ) + dup bwjoin ( lrgain ) + 0 ( lrgain boost ) + then ( lrgain boost ) + then ( lrgain boost ) +; +: set-dac-gain ( n -- ) + dup d# -96 < if outmix-mute-dac else outmix-unmute-dac then + gain>lr-3/8 h# 0c codec! h# 10 codec! +; +: set-adc-gain ( n -- ) + gain>lr-3/8 h# 12 codec! h# 16 codec! +; +: mic1-balanced ( -- ) h# 8000 h# 8000 h# 0e codec-field ; +: mic1-single-ended ( -- ) 0 h# 8000 h# 0e codec-field ; +: mic2-balanced ( -- ) h# 0080 h# 0080 h# 0e codec-field ; +: mic2-single-ended ( -- ) 0 h# 0080 h# 0e codec-field ; + +false value external-mic? +: mic-routing ( -- n ) + mic1-single-ended mic2-single-ended + adc-unmute-mic +; +: db>mic-boost ( db -- code ) + dup d# 52 >= if drop h# 8800 exit then + dup d# 50 >= if drop h# 7700 exit then + dup d# 44 >= if drop h# 6600 exit then + dup d# 40 >= if drop h# 5500 exit then + dup d# 35 >= if drop h# 4400 exit then + dup d# 30 >= if drop h# 3300 exit then + dup d# 24 >= if drop h# 2200 exit then + dup d# 20 >= if drop h# 1100 exit then + drop h# 0000 +; +: set-mic-gain ( db -- ) + db>mic-boost h# ff00 h# 22 codec-field + mic-routing +; +: mic+0db ( -- ) 0 set-mic-gain ; +: mic+20db ( -- ) d# 20 set-mic-gain ; +: set-default-gains ( -- ) + output-config + headphones-inserted? if + default-headphone-volume set-headphone-volume + mute-speakers + else + default-speaker-volume set-speaker-volume + mute-headphones + then + default-dac-gain set-dac-gain + default-mic-gain set-mic-gain + default-adc-gain set-adc-gain +; + +: set-codec-sample-rate ( rate -- ) + case + d# 8000 of h# 2222 h# 5272 endof + d# 16000 of h# 2020 h# 2272 endof + d# 32000 of h# 2121 h# 2172 endof + d# 48000 of h# 0000 h# 3072 endof + ( default ) true abort" Unsupported audio sample rate" + endcase ( reg62val2 reg60val ) + h# 60 codec! h# 62 codec! +; + +\ LICENSE_BEGIN +\ Copyright (c) 2011 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 Modified: cpu/arm/olpc/1.75/sound.fth ============================================================================== --- cpu/arm/olpc/1.75/sound.fth Sat Jan 8 10:49:39 2011 (r2102) +++ cpu/arm/olpc/1.75/sound.fth Sat Jan 8 11:11:59 2011 (r2103) @@ -187,62 +187,6 @@ r> codec! ( ) ; -: codec-bias-off ( -- ) -[ifdef] cl2-a1 - h# 8080 h# 02 codec-set -[else] - h# c0c0 h# 02 codec-set -[then] - h# 8080 h# 04 codec-set - h# 0000 h# 3a codec! - h# 0000 h# 3c codec! - h# 0000 h# 3e codec! -; -: linux-codec-on - h# 0000 h# 26 codec! \ Don't power down any groups - h# 8000 h# 5e codec! \ Disable fast vref - h# 0c00 h# 3e codec! \ enable HP out volume power - h# 0002 h# 3a codec! \ enable Main bias - h# 2000 h# 3c codec! \ enable Vref - h# 6808 h# 0c codec! \ Stereo DAC Volume - h# 3f3f h# 14 codec! \ ADC Record Mixer Control - h# 4b40 h# 1c codec! \ Output Mixer Control - h# 0500 h# 22 codec! \ Microphone Control - h# 04e8 h# 40 codec! \ General Purpose Control -; -: codec-on ( -- ) -[ifdef] cl2-a1 - h# 30 1 set-twsi-target - h# 0000 h# 26 codec! \ Don't power down any groups - h# 8002 h# 34 codec! \ Slave mode, 16 bits, left justified - b# 1000.1000.0011.1111 h# 3a codec! \ All on except MONO depop, 0-cross - b# 1010.0011.1111.0011 h# 3c codec! \ All on except ClassAB, PLL, speaker mixer, MONO mixer - b# 0011.1111.1100.1111 h# 3e codec! \ All on except MONO_OUT and PHONE in - h# 0140 h# 40 codec! \ MCLK is SYSCLK, HPamp Vmid 1.25, ClassDamp Vmid 1.5 -[else] - h# 34 1 set-twsi-target - h# 8001 h# 34 codec! \ Slave mode, 16 bits, left justified - b# 1001.1111.1110.0000 h# 3a codec! \ All on - b# 1111.1100.0011.1100 h# 3b codec! \ All on except PLL - b# 1010.0000.0001.1101 h# 3c codec! \ All on except AX and MONO - b# 1111.1100.0000.0000 h# 3e codec! \ AXI and MONO IN off -\ h# 8c00 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, use HPFs - h# 8000 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, no HPFs - h# 0000 h# 42 codec! \ Use MCLK, not PLL - b# 1110.1100.1001.0000 h# 52 codec! \ Protection on - h# 4000 h# 56 codec! \ Power on Cap-free block with de-pop -[then] -; -: codec-off ( -- ) -[ifdef] cl2-a1 - h# ef00 h# 26 codec! \ Power down everything -[else] - 0 h# 3a codec! \ All off - 0 h# 3b codec! \ All off - 0 h# 3c codec! \ All off - 0 h# 3e codec! \ All off -[then] -; d# 48000 value sample-rate \ Longest time to wait for a buffer event - a little more @@ -250,20 +194,18 @@ \ at the current sample rate. 0 value buf-timeout -: set-sample-rate ( rate -- ) - to sample-rate - sample-rate case - d# 8000 of h# 2222 h# 5272 d# 48 d# 129 endof - d# 16000 of h# 2020 h# 2272 d# 24 d# 65 endof - d# 32000 of h# 2121 h# 2172 d# 12 d# 33 endof - d# 48000 of h# 0000 h# 3072 d# 8 d# 23 endof +: set-ctlr-sample-rate ( rate -- ) + case + d# 8000 of d# 48 d# 129 endof + d# 16000 of d# 24 d# 65 endof + d# 32000 of d# 12 d# 33 endof + d# 48000 of d# 8 d# 23 endof ( default ) true abort" Unsupported audio sample rate" - endcase ( reg62val2 reg60val sspareg34val timeout ) + endcase ( sspareg34val timeout ) to buf-timeout - 9 lshift h# 183 or h# 34 sspa! h# 60 codec! h# 62 codec! + 9 lshift h# 183 or h# 34 sspa! ; -\ Mic bias 2 is for external mic \ I think we don't need to use the audio PLL, because we are using the PMUM M/N divider \ DIV_MCL 0 DIV_FBCLK 01 FRACT 00da1 \ POSTDIV 1 DIV_OCLK_MODULO 000 (NA) DIV_OCLK_PATTERN 00 (NA) @@ -404,262 +346,24 @@ [then] [ifdef] cl2-a1 -\ Realtek ALC5624 CODEC -: mic-gain ( bits11:8 -- ) h# f00 h# 22 codec-field ; -: mic+0db ( -- ) 0 mic-gain ; \ Needed -: mic+20db ( -- ) h# 500 mic-gain ; \ Needed -: mic+30db ( -- ) h# a00 mic-gain ; -: mic+40db ( -- ) h# f00 mic-gain ; - -: mic-bias-off ( -- ) h# 000c h# 3a codec-clr ; -: mic-bias-on ( -- ) h# 000c h# 3a codec-set ; - -: mic1-high-bias ( -- ) h# 20 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V -: mic1-low-bias ( -- ) h# 20 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V -: mic2-high-bias ( -- ) h# 10 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V -: mic2-low-bias ( -- ) h# 21 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V - -\ The mic bias short circuit detection threshold can be set with reg 0x22 bits 1:0 - -\ 00:600uA 01:1200uA 1x:1800uA -\ 600uA is probably good for OLPC, since the 5.6K bias resistor limits the SC current to less than that. - -\ Sets both speakers simultaneously -: speakers-source ( value -- ) h# d800 h# 1c codec-field ; - -: speakers-off ( -- ) 0 speakers-source ; -: hp-mixer>speakers ( -- ) h# 4800 speakers-source ; -: speaker-mixer>speakers ( -- ) h# 9000 speakers-source ; -: mono>speakers ( -- ) h# d800 speakers-source ; - -: class-ab-speakers ( -- ) h# 2000 h# 1c codec-clr ; -: class-d-speakers ( -- ) h# 2000 h# 1c codec-set ; - -: headphones-off ( -- ) h# 300 h# 1c codec-clr ; -: headphones-on ( -- ) h# 300 h# 1c codec-set ; - -0 [if] \ OLPC does not connect the MONO output -: mono-source ( value -- ) h# c0 h# 1c codec-field ; -: mono-off ( -- ) 0 mono-source ; -: hp-mixer>mono ( -- ) h# 40 mono-source ; -: speaker-mixer>mono ( -- ) h# 80 mono-source ; -: mono-mixer>mono ( -- ) h# c0 mono-source ; -[then] +: init-smbus ( -- ) h# 30 1 set-twsi-target ; -: headphones-inserted? ( -- flag ) h# 54 codec@ 2 and 0<> ; - -\ The range is from -34.5 db to +12 dB -: gain>lr ( db -- true | regval false ) - 2* 3 / ( steps ) \ Converts -34.5 .. 12 db to -23 .. 8 steps - dup d# -23 < if ( steps ) - drop true - else ( steps ) - 8 swap - ( -steps ) - 0 max ( clipped-steps ) - dup 8 lshift or ( regval ) - false - then -; -\ The range is from -46.5 db to 0 dB -: >output-volume ( db -- regval mask ) - d# 12 + \ Bias to the range used by gain>lr - gain>lr if h# 8080 then h# 9f9f -; -: set-speaker-volume ( n -- ) >output-volume 2 codec-field ; -: set-headphone-volume ( n -- ) >output-volume 4 codec-field ; -\ : set-mono-volume ( n -- ) >output-volume 6 codec-field ; -: set-volume ( n -- ) - dup set-speaker-volume set-headphone-volume -; -d# 0 constant default-adc-gain \ 0 dB - range is -16.5 to +30 -d# 0 constant default-dac-gain \ 0 dB - range is -34.5 to +12 -d# 44 constant default-mic-gain \ 44 dB - range is -34.5 to -d# 0 constant default-speaker-volume \ 0 dB - range is -46.5 to 0 -d# 0 constant default-headphone-volume \ 0 dB - range is -46.5 to 0 - -: select-headphones ( -- ) h# 300 h# 1c codec! ; -: select-speakers-ab ( -- ) h# 4800 h# 1c codec! ; \ ClassAB, headphone mixer -: select-speakers ( -- ) h# 6800 h# 1c codec! ; \ ClassD, headphone mixer - -: set-line-in-gain ( n -- ) - gain>lr if h# e000 then h# ff1f h# 0a codec-field -; -: set-dac-gain ( n -- ) - gain>lr if h# e000 then h# ff1f h# 0c codec-field -; -false value external-mic? -: mic-routing ( -- n ) - \ Mute selected MIC inputs to the ADC as follows: - \ For external, we send MIC1 to left and MIC2 to right - \ For internal, we send MIC1 to both left and right - external-mic? if h# 2040 else h# 2020 then -; -: set-mic-boost ( db -- db' ) - dup d# 26 > if mic+40db d# 40 - exit then - dup d# 16 > if mic+30db d# 30 - exit then - dup d# 06 > if mic+20db d# 20 - exit then - mic+0db -; -: set-mic-gain ( db -- ) - set-mic-boost ( db' ) - gain>lr if ( ) \ Mute - \ Turn everything off - mic-bias-off ( ) - 0 h# 6060 h# e0e0 ( gain adc-mute mic-output-mute ) - else ( gain ) - mic-bias-on ( gain ) - \ Mic routing to ADC depends on internal or external mic - mic-routing ( gain adc-mute ) - \ To avoid feedback, we do not feedthrough the mic - h# e0e0 ( gain adc-mute mic-output-mute ) - then ( gain adc-mute mic-output-mute ) - h# e0e0 h# 10 codec-field ( gain adc-mute ) - h# 6060 h# 14 codec-field ( gain ) - h# 1f1f h# 0e codec-field -; -: set-adc-gain ( db -- ) \ Range is -16.5 dB to +30 dB - d# 18 - ( db' ) - gain>lr if 0 then ( gain ) - h# f9f h# 12 codec-field - h# 60 h# 12 codec-set \ Enable ADC zero-cross detectors -; +fload ${BP}/cpu/arm/olpc/1.75/alc5624.fth \ Realtek ALC5624 CODEC [else] -\ Realtek ALC5631Q CODEC -: mic-bias-off ( -- ) h# 000c h# 3b codec-clr ; -: mic-bias-on ( -- ) h# 000c h# 3b codec-set ; - -: mic1-high-bias ( -- ) h# 80 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V -: mic1-low-bias ( -- ) h# 80 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V -: mic2-high-bias ( -- ) h# 08 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V -: mic2-low-bias ( -- ) h# 08 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V +: init-smbus ( -- ) h# 34 1 set-twsi-target ; : headphones-inserted? ( -- flag ) d# 97 gpio-pin@ ; : microphone-inserted? ( -- flag ) d# 96 gpio-pin@ ; -\ The range is from -46.5 db to +12 dB -: gain>lr-12 ( db -- true | regval false ) - d# 12 min ( db' ) - 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps - dup d# -31 < if ( steps ) - drop true - else ( steps ) - 8 swap - ( -steps ) - 0 max ( clipped-steps ) - dup 8 lshift or ( regval ) - false - then -; -\ The range is from -46.5 db to 0 dB -: gain>lr ( db -- true | regval false ) - 0 min ( db' ) - 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps - dup d# -31 < if ( steps ) - drop true - else ( steps ) - 0 swap - ( -steps ) - 0 max ( clipped-steps ) - dup 8 lshift or ( regval ) - false - then -; - -\ This sets up a simple routing from the DAC to the headphone and speaker outputs -: output-config ( -- ) - h# df00 h# 1a codec! \ DACL -> OUTMIXL - h# df00 h# 1c codec! \ DACR -> OUTMIXR - h# 4040 h# 04 codec-set \ OUTMIXLR -> HPOVOLLR - h# d0d0 h# 28 codec! \ DACLR -> SPKMIXLR - h# 4040 h# 02 codec-set \ SPKMIXLR -> SPKVOLLR - h# 9000 h# 2a codec! \ SPKVOLL -> SPOLMIX, SPKVOLR -> SPORMIX - h# 0000 h# 2c codec! \ SPOxMIX -> SPKRMUX, HPOVOL -> HPMUX -; - -: mute-speakers ( -- ) h# 8080 2 codec-set ; -: set-speaker-volume ( n -- ) \ DONE - gain>lr-12 if h# 8080 then h# bfbf 2 codec-field -; -: mute-headphones ( -- ) h# 8080 4 codec-set ; -: set-headphone-volume ( n -- ) \ DONE - gain>lr if h# 8080 then h# 9f9f 4 codec-field -; -: set-volume ( n -- ) - headphones-inserted? if - set-headphone-volume - else - set-speaker-volume - then -; -d# 0 constant default-adc-gain \ 0 dB - range is -96.625 to +28.5 -d# 0 constant default-dac-gain \ 0 dB - range is -96.625 to +28.5 -d# 44 constant default-mic-gain \ 44 dB - range is 0 to 50 dB -d# 0 constant default-speaker-volume \ 0 dB - range is -46.5 to +12 -d# -10 constant default-headphone-volume \ -10 dB - range is -46.5 to 0 - -: adc-mute-all ( -- ) h# f0f0 h# 14 codec! ; -: adc-mute-mic ( -- ) h# 4040 h# 14 codec-set ; -: adc-unmute-mic ( -- ) h# 4040 h# 14 codec-clr ; -\ : adc-unmute-outmix ( -- ) h# 8080 h# 14 codec-clr ; - -\ The useful one is outmix-unmute-dac -: outmix-mute-all ( -- ) h# ff00 dup h# 1a codec! h# 1c codec! ; -: outmix-mute-mic ( -- ) h# 1000 dup h# 1a codec-set h# 1c codec-set ; -: outmix-unmute-mic ( -- ) h# 1000 dup h# 1a codec-clr h# 1c codec-clr ; -: outmix-mute-dac ( -- ) h# 2000 dup h# 1a codec-set h# 1c codec-set ; -: outmix-unmute-dac ( -- ) h# 2000 dup h# 1a codec-clr h# 1c codec-clr ; -: outmix-mute-recmix ( -- ) h# 8000 dup h# 1a codec-set h# 1c codec-set ; -: outmix-unmute-recmix ( -- ) h# 8000 dup h# 1a codec-clr h# 1c codec-clr ; - -: gain>lr-3/8 ( -- lrgain boost ) - d# 28 min - dup 0>= if ( n ) - 8 3 */ ( boost ) \ Convert to .375 dB increments - 0 swap ( lrgain boost ) - else ( n ) - dup d# -96 <= if ( n ) - drop ( ) - h# ffff h# 8080 ( lrgain boost ) - else ( n ) - negate 8 3 */ ( steps ) - dup bwjoin ( lrgain ) - 0 ( lrgain boost ) - then ( lrgain boost ) - then ( lrgain boost ) -; -: set-dac-gain ( n -- ) - dup d# -96 < if outmix-mute-dac else outmix-unmute-dac then - gain>lr-3/8 h# 0c codec! h# 10 codec! -; -: set-adc-gain ( n -- ) - gain>lr-3/8 h# 12 codec! h# 16 codec! -; -: mic1-balanced ( -- ) h# 8000 h# 8000 h# 0e codec-field ; -: mic1-single-ended ( -- ) 0 h# 8000 h# 0e codec-field ; -: mic2-balanced ( -- ) h# 0080 h# 0080 h# 0e codec-field ; -: mic2-single-ended ( -- ) 0 h# 0080 h# 0e codec-field ; - -false value external-mic? -: mic-routing ( -- n ) - mic1-single-ended mic2-single-ended - adc-unmute-mic -; -: db>mic-boost ( db -- code ) - dup d# 52 >= if drop h# 8800 exit then - dup d# 50 >= if drop h# 7700 exit then - dup d# 44 >= if drop h# 6600 exit then - dup d# 40 >= if drop h# 5500 exit then - dup d# 35 >= if drop h# 4400 exit then - dup d# 30 >= if drop h# 3300 exit then - dup d# 24 >= if drop h# 2200 exit then - dup d# 20 >= if drop h# 1100 exit then - drop h# 0000 -; -: set-mic-gain ( db -- ) - db>mic-boost h# ff00 h# 22 codec-field - mic-routing -; -: mic+0db ( -- ) 0 set-mic-gain ; -: mic+20db ( -- ) d# 20 set-mic-gain ; +fload ${BP}/cpu/arm/olpc/1.75/alc5631.fth \ Realtek ALC5631Q CODEC [then] +: set-sample-rate ( rate -- ) + dup to sample-rate + dup set-ctlr-sample-rate + set-codec-sample-rate +; + \ This is called from "record" in "mic-test" in "selftest" : set-record-gain ( db -- ) \ translate value from ac97 selftest code into our default value @@ -674,24 +378,9 @@ : mono ; : init-codec ( -- ) + init-smbus codec-on -[ifdef] cl2-a1 - headphones-inserted? if select-headphones else select-speakers then - default-speaker-volume set-speaker-volume - default-headphone-volume set-headphone-volume -[else] - output-config - headphones-inserted? if - default-headphone-volume set-headphone-volume - mute-speakers - else - default-speaker-volume set-speaker-volume - mute-headphones - then -[then] - default-dac-gain set-dac-gain - default-mic-gain set-mic-gain - default-adc-gain set-adc-gain + set-default-gains d# 48000 set-sample-rate ; 0 value open-count @@ -712,3 +401,27 @@ fload ${BP}/dev/geode/ac97/selftest.fth end-package + +\ LICENSE_BEGIN +\ Copyright (c) 2011 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
1
0
0
0
[commit] r2102 - cpu/arm/olpc/1.75
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 10:49:39 2011 New Revision: 2102 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2102
Log: OLPC XO-1.75 A2 - support Realtek ALC5631Q CODEC Modified: cpu/arm/olpc/1.75/sound.fth Modified: cpu/arm/olpc/1.75/sound.fth ============================================================================== --- cpu/arm/olpc/1.75/sound.fth Sat Jan 8 10:28:40 2011 (r2101) +++ cpu/arm/olpc/1.75/sound.fth Sat Jan 8 10:49:39 2011 (r2102) @@ -188,7 +188,11 @@ ; : codec-bias-off ( -- ) +[ifdef] cl2-a1 h# 8080 h# 02 codec-set +[else] + h# c0c0 h# 02 codec-set +[then] h# 8080 h# 04 codec-set h# 0000 h# 3a codec! h# 0000 h# 3c codec! @@ -196,7 +200,7 @@ ; : linux-codec-on h# 0000 h# 26 codec! \ Don't power down any groups - h# 8000 h# 53 codec! \ Disable fast vref + h# 8000 h# 5e codec! \ Disable fast vref h# 0c00 h# 3e codec! \ enable HP out volume power h# 0002 h# 3a codec! \ enable Main bias h# 2000 h# 3c codec! \ enable Vref @@ -207,6 +211,7 @@ h# 04e8 h# 40 codec! \ General Purpose Control ; : codec-on ( -- ) +[ifdef] cl2-a1 h# 30 1 set-twsi-target h# 0000 h# 26 codec! \ Don't power down any groups h# 8002 h# 34 codec! \ Slave mode, 16 bits, left justified @@ -214,9 +219,29 @@ b# 1010.0011.1111.0011 h# 3c codec! \ All on except ClassAB, PLL, speaker mixer, MONO mixer b# 0011.1111.1100.1111 h# 3e codec! \ All on except MONO_OUT and PHONE in h# 0140 h# 40 codec! \ MCLK is SYSCLK, HPamp Vmid 1.25, ClassDamp Vmid 1.5 +[else] + h# 34 1 set-twsi-target + h# 8001 h# 34 codec! \ Slave mode, 16 bits, left justified + b# 1001.1111.1110.0000 h# 3a codec! \ All on + b# 1111.1100.0011.1100 h# 3b codec! \ All on except PLL + b# 1010.0000.0001.1101 h# 3c codec! \ All on except AX and MONO + b# 1111.1100.0000.0000 h# 3e codec! \ AXI and MONO IN off +\ h# 8c00 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, use HPFs + h# 8000 h# 40 codec! \ Speaker Amp Auto Ratio GAIN, no HPFs + h# 0000 h# 42 codec! \ Use MCLK, not PLL + b# 1110.1100.1001.0000 h# 52 codec! \ Protection on + h# 4000 h# 56 codec! \ Power on Cap-free block with de-pop +[then] ; : codec-off ( -- ) +[ifdef] cl2-a1 h# ef00 h# 26 codec! \ Power down everything +[else] + 0 h# 3a codec! \ All off + 0 h# 3b codec! \ All off + 0 h# 3c codec! \ All off + 0 h# 3e codec! \ All off +[then] ; d# 48000 value sample-rate @@ -378,6 +403,8 @@ \ Page 1498 - The data transmit register is listed as RO. How can a transmit register be RO???? [then] +[ifdef] cl2-a1 +\ Realtek ALC5624 CODEC : mic-gain ( bits11:8 -- ) h# f00 h# 22 codec-field ; : mic+0db ( -- ) 0 mic-gain ; \ Needed : mic+20db ( -- ) h# 500 mic-gain ; \ Needed @@ -495,6 +522,143 @@ h# f9f h# 12 codec-field h# 60 h# 12 codec-set \ Enable ADC zero-cross detectors ; +[else] +\ Realtek ALC5631Q CODEC +: mic-bias-off ( -- ) h# 000c h# 3b codec-clr ; +: mic-bias-on ( -- ) h# 000c h# 3b codec-set ; + +: mic1-high-bias ( -- ) h# 80 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic1-low-bias ( -- ) h# 80 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V +: mic2-high-bias ( -- ) h# 08 h# 22 codec-clr mic-bias-on ; \ 0.90*AVDD, e.g. 3V with AVDD=3.3V +: mic2-low-bias ( -- ) h# 08 h# 22 codec-set mic-bias-on ; \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V + +: headphones-inserted? ( -- flag ) d# 97 gpio-pin@ ; +: microphone-inserted? ( -- flag ) d# 96 gpio-pin@ ; + +\ The range is from -46.5 db to +12 dB +: gain>lr-12 ( db -- true | regval false ) + d# 12 min ( db' ) + 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps + dup d# -31 < if ( steps ) + drop true + else ( steps ) + 8 swap - ( -steps ) + 0 max ( clipped-steps ) + dup 8 lshift or ( regval ) + false + then +; +\ The range is from -46.5 db to 0 dB +: gain>lr ( db -- true | regval false ) + 0 min ( db' ) + 2* 3 / ( steps ) \ Converts -46.5 .. 12 db to -31 .. 8 steps + dup d# -31 < if ( steps ) + drop true + else ( steps ) + 0 swap - ( -steps ) + 0 max ( clipped-steps ) + dup 8 lshift or ( regval ) + false + then +; + +\ This sets up a simple routing from the DAC to the headphone and speaker outputs +: output-config ( -- ) + h# df00 h# 1a codec! \ DACL -> OUTMIXL + h# df00 h# 1c codec! \ DACR -> OUTMIXR + h# 4040 h# 04 codec-set \ OUTMIXLR -> HPOVOLLR + h# d0d0 h# 28 codec! \ DACLR -> SPKMIXLR + h# 4040 h# 02 codec-set \ SPKMIXLR -> SPKVOLLR + h# 9000 h# 2a codec! \ SPKVOLL -> SPOLMIX, SPKVOLR -> SPORMIX + h# 0000 h# 2c codec! \ SPOxMIX -> SPKRMUX, HPOVOL -> HPMUX +; + +: mute-speakers ( -- ) h# 8080 2 codec-set ; +: set-speaker-volume ( n -- ) \ DONE + gain>lr-12 if h# 8080 then h# bfbf 2 codec-field +; +: mute-headphones ( -- ) h# 8080 4 codec-set ; +: set-headphone-volume ( n -- ) \ DONE + gain>lr if h# 8080 then h# 9f9f 4 codec-field +; +: set-volume ( n -- ) + headphones-inserted? if + set-headphone-volume + else + set-speaker-volume + then +; +d# 0 constant default-adc-gain \ 0 dB - range is -96.625 to +28.5 +d# 0 constant default-dac-gain \ 0 dB - range is -96.625 to +28.5 +d# 44 constant default-mic-gain \ 44 dB - range is 0 to 50 dB +d# 0 constant default-speaker-volume \ 0 dB - range is -46.5 to +12 +d# -10 constant default-headphone-volume \ -10 dB - range is -46.5 to 0 + +: adc-mute-all ( -- ) h# f0f0 h# 14 codec! ; +: adc-mute-mic ( -- ) h# 4040 h# 14 codec-set ; +: adc-unmute-mic ( -- ) h# 4040 h# 14 codec-clr ; +\ : adc-unmute-outmix ( -- ) h# 8080 h# 14 codec-clr ; + +\ The useful one is outmix-unmute-dac +: outmix-mute-all ( -- ) h# ff00 dup h# 1a codec! h# 1c codec! ; +: outmix-mute-mic ( -- ) h# 1000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-mic ( -- ) h# 1000 dup h# 1a codec-clr h# 1c codec-clr ; +: outmix-mute-dac ( -- ) h# 2000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-dac ( -- ) h# 2000 dup h# 1a codec-clr h# 1c codec-clr ; +: outmix-mute-recmix ( -- ) h# 8000 dup h# 1a codec-set h# 1c codec-set ; +: outmix-unmute-recmix ( -- ) h# 8000 dup h# 1a codec-clr h# 1c codec-clr ; + +: gain>lr-3/8 ( -- lrgain boost ) + d# 28 min + dup 0>= if ( n ) + 8 3 */ ( boost ) \ Convert to .375 dB increments + 0 swap ( lrgain boost ) + else ( n ) + dup d# -96 <= if ( n ) + drop ( ) + h# ffff h# 8080 ( lrgain boost ) + else ( n ) + negate 8 3 */ ( steps ) + dup bwjoin ( lrgain ) + 0 ( lrgain boost ) + then ( lrgain boost ) + then ( lrgain boost ) +; +: set-dac-gain ( n -- ) + dup d# -96 < if outmix-mute-dac else outmix-unmute-dac then + gain>lr-3/8 h# 0c codec! h# 10 codec! +; +: set-adc-gain ( n -- ) + gain>lr-3/8 h# 12 codec! h# 16 codec! +; +: mic1-balanced ( -- ) h# 8000 h# 8000 h# 0e codec-field ; +: mic1-single-ended ( -- ) 0 h# 8000 h# 0e codec-field ; +: mic2-balanced ( -- ) h# 0080 h# 0080 h# 0e codec-field ; +: mic2-single-ended ( -- ) 0 h# 0080 h# 0e codec-field ; + +false value external-mic? +: mic-routing ( -- n ) + mic1-single-ended mic2-single-ended + adc-unmute-mic +; +: db>mic-boost ( db -- code ) + dup d# 52 >= if drop h# 8800 exit then + dup d# 50 >= if drop h# 7700 exit then + dup d# 44 >= if drop h# 6600 exit then + dup d# 40 >= if drop h# 5500 exit then + dup d# 35 >= if drop h# 4400 exit then + dup d# 30 >= if drop h# 3300 exit then + dup d# 24 >= if drop h# 2200 exit then + dup d# 20 >= if drop h# 1100 exit then + drop h# 0000 +; +: set-mic-gain ( db -- ) + db>mic-boost h# ff00 h# 22 codec-field + mic-routing +; +: mic+0db ( -- ) 0 set-mic-gain ; +: mic+20db ( -- ) d# 20 set-mic-gain ; +[then] \ This is called from "record" in "mic-test" in "selftest" : set-record-gain ( db -- ) @@ -511,9 +675,20 @@ : init-codec ( -- ) codec-on +[ifdef] cl2-a1 headphones-inserted? if select-headphones else select-speakers then default-speaker-volume set-speaker-volume default-headphone-volume set-headphone-volume +[else] + output-config + headphones-inserted? if + default-headphone-volume set-headphone-volume + mute-speakers + else + default-speaker-volume set-speaker-volume + mute-headphones + then +[then] default-dac-gain set-dac-gain default-mic-gain set-mic-gain default-adc-gain set-adc-gain
1
0
0
0
[commit] r2101 - dev/mmc/sdhci
by repository service
08 Jan '11
08 Jan '11
Author: wmb Date: Sat Jan 8 10:28:40 2011 New Revision: 2101 URL:
http://tracker.coreboot.org/trac/openfirmware/changeset/2101
Log: SDHCI - improve support for MMC cards so eMMC on XO-1.75 A2 works. Modified: dev/mmc/sdhci/sdhci.fth Modified: dev/mmc/sdhci/sdhci.fth ============================================================================== --- dev/mmc/sdhci/sdhci.fth Sat Jan 8 10:23:46 2011 (r2100) +++ dev/mmc/sdhci/sdhci.fth Sat Jan 8 10:28:40 2011 (r2101) @@ -74,8 +74,16 @@ : host-high-speed ( -- ) h# 28 cb@ 4 or h# 28 cb! ; : host-low-speed ( -- ) h# 28 cb@ 4 invert and h# 28 cb! ; -: 4-bit ( -- ) h# 28 cb@ 2 or h# 28 cb! ; -: 1-bit ( -- ) h# 28 cb@ 2 invert and h# 28 cb! ; +: 4-bit ( -- ) h# 28 cb@ h# 20 invert and 2 or h# 28 cb! ; +: 1-bit ( -- ) h# 28 cb@ h# 22 invert and h# 28 cb! ; + +: hc-supports-8-bit? ( -- flag ) + h# 28 cb@ ( old-val ) + dup h# 20 or h# 28 cb! ( old-val ) + h# 28 cb@ h# 20 and 0<> ( old-val flag ) + swap h# 28 cb! ( flag ) +; +: 8-bit ( -- ) h# 28 cb@ h# 20 or h# 28 cb! ; \ : led-on ( -- ) h# 28 cb@ 1 or h# 28 cb! ; \ : led-off ( -- ) h# 28 cb@ 1 invert and h# 28 cb! ; @@ -428,6 +436,9 @@ dma-release scratch-buf ; +: mmc-switch ( arg -- ) \ CMD6 for MMC - no data + h# 061b 0 cmd response h# 80 and if ." MMC SWITCH_ERROR" cr then +; : deselect-card ( -- ) 0 h# 0700 0 cmd ; \ CMD7 - with null RCA : select-card ( -- ) \ CMD7 R1b @@ -511,6 +522,34 @@ intstat-off ; +\ The bit numbering follows the table on page 78 of the +\ SD Physical Layer Simplified Specification Version 2.00. + +\ The "8 -" accounts for the fact that the chip's response +\ registers omit the CRC and tag in bits [7:0] +: csdbit ( bit# -- b ) + 8 - + dup 3 rshift csd + c@ ( bit# byte ) + swap 7 and rshift 1 and +; +: csdbits ( high low -- bits ) + swap 0 -rot do 2* i csdbit or -1 +loop +; + +: mmc-v4? ( -- flag ) d# 125 d# 122 csdbits 4 >= ; + +\ This sends back 512 bytes in a single data block. +0 instance value ext-csd-buf + +\ Must be called with inststat-on +: get-ext-csd ( -- ) \ CMD8 R1 + d# 512 " dma-alloc" $call-parent to ext-csd-buf + ext-csd-buf d# 512 dup (dma-setup) + 0 h# 083a h# 13 cmd + 2 wait + dma-release +; + \ Decoder for the result of ACMD13 - app-get-status : sdstatbit ( bit# -- b ) d# 511 swap - ( bit#' ) @@ -540,7 +579,13 @@ \ Using this before a write-multiple command speeds up the write by \ avoiding unnecessary preservation of data that will be clobbered. -: pre-write-erase ( #blocks -- ) intstat-on app-prefix ( #blocks ) h# 171a 0 cmd ; \ ACMD23 R1 +: pre-write-erase ( #blocks -- ) + mmc? if + drop + else + intstat-on app-prefix ( #blocks ) h# 171a 0 cmd \ ACMD23 R1 + then +; \ You might want to turn this off for data transfer, as it controls \ a resistor on one of the data lines @@ -661,7 +706,7 @@ \ SD version 2 adds CMD8. Pre-v2 cards will time out. false to timeout? send-if-cond ( ) - timeout? if h# 0030.0000 else h# 4030.0000 then to oc-mode + timeout? if h# 40ff.8000 else h# 4030.0000 then to oc-mode wait-powered if true exit then @@ -696,13 +741,46 @@ then ; +: ext-csd-set ( mask index -- ) 0 -rot 1 bljoin mmc-switch ; +: ext-csd-clr ( mask index -- ) 0 -rot 2 bljoin mmc-switch ; +: ext-csd! ( value index -- ) 0 -rot 3 bljoin mmc-switch ; +: mmc-ddr-4-bit ( -- ) 5 d# 183 ext-csd! ; +: mmc-ddr-8-bit ( -- ) 6 d# 183 ext-csd! ; +: mmc-1-bit ( -- ) 0 d# 183 ext-csd! ; +: mmc-4-bit ( -- ) 1 d# 183 ext-csd! ; +: mmc-8-bit ( -- ) 2 d# 183 ext-csd! ; +: mmc-high-speed ( -- ) 1 d# 185 ext-csd! ; +: mmc-26-mhz? ( -- flag ) d# 196 ext-csd-buf + c@ 1 and 0<> ; +: mmc-52-mhz? ( -- flag ) d# 196 ext-csd-buf + c@ 2 and 0<> ; +: configure-mmc ( -- ) + mmc-v4? if + get-ext-csd \ MMC Cmd 8 - Get extended CSD + + \ Ideally, the width selection would be done by using CMD19 to test the bus + hc-supports-8-bit? if + mmc-8-bit 8-bit + else + mmc-4-bit 4-bit + then + + \ Ideally, we should set the speed class/power consumption - but the devices + \ I have don't really care, so it's hard to test. + + mmc-52-mhz? if + mmc-high-speed card-clock-50 + else + mmc-26-mhz? if + mmc-high-speed card-clock-25 + then + then + else + \ Pre-v4 MMC cards do not support SWITCH, so the only choice is 1-bit + 1-bit + then +; : configure-transfer ( -- ) mmc? if - 1-bit - \ We don't support 4-bit mode for MMC yet - - \ We don't support switching to high speed on MMC yet. - \ Doing so requires reading the EXT_CSD block + configure-mmc else 2 set-bus-width \ acmd6 - bus width 4 4-bit @@ -897,12 +975,14 @@ get-all-cids \ Cmd 2 mmc? if - h# 10000 set-rca \ Cmd 3 (MMC) - Get relative card address + h# 20000 set-rca \ Cmd 3 (MMC) - Get relative card address else get-rca \ Cmd 3 (SD) - Get relative card address then - card-clock-25 + mmc? 0= if + card-clock-25 + then get-csd \ Cmd 9 - Get card-specific data get-cid \ Cmd 10 - Get card ID @@ -1034,6 +1114,7 @@ : close ( -- ) open-count 1 = if scratch-buf d# 64 " dma-free" $call-parent + ext-csd-buf if ext-csd-buf d# 512 " dma-free" $call-parent then then open-count 1- 0 max to open-count ; @@ -1060,23 +1141,14 @@ r> base ! ; -\ The bit numbering follows the table on page 78 of the -\ SD Physical Layer Simplified Specification Version 2.00. - -\ The "8 -" accounts for the fact that the chip's response -\ registers omit the CRC and tag in bits [7:0] -: csdbit ( bit# -- b ) - 8 - - dup 3 rshift csd + c@ ( bit# byte ) - swap 7 and rshift 1 and -; -: csdbits ( high low -- bits ) - swap 0 -rot do 2* i csdbit or -1 +loop -; - \ The calculation below is shown on page 81 of the \ SD Physical Layer Simplified Specification Version 2.00. : size ( -- d.bytes ) + ext-csd-buf if + ext-csd-buf d# 212 + le-l@ d# 512 um* + exit + then + d# 127 d# 126 csdbits case 0 of d# 49 d# 47 csdbits ( c_size_mult )
1
0
0
0
← Newer
1
2
3
4
5
6
7
Older →
Jump to page:
1
2
3
4
5
6
7
Results per page:
10
25
50
100
200