📄 bbu_codec.s
字号:
;*********************************************************************************
;
; COPYRIGHT (C) 2006 Marvell International Ltd. All Rights Reserved.
;
; The information in this file is furnished for informational use only,
; is subject to change without notice, and should not be construed as
; a commitment by Marvell. Marvell assumes no responsibility or liability
; for any errors or inaccuracies that may appear in this software or any
; documenation that may be provided in association with this software.
;
;*********************************************************************************
;
; bbu_Codec.s
; Assorted subroutines for the DA9034 audio codec
;
; List of subroutines in this file:
;
;
; BBU_CODEC_INIT Init the codec for use
;
;
INCLUDE xlli_PXA3xx_defs.inc ; XLLI specific definitions for Monahans
INCLUDE bbu_Monahans_defs.inc ; BBU specific definitions for Monahans
GLOBAL BBU_CODEC_INIT ; Init Codec Interface
GLOBAL BBU_TSI_VALU ; Get Touch Screen Interface Values
GLOBAL BBU_TSI_TEST ; Touch Screen Interface Test
GLOBAL BBU_SPKR_VOL ; Speaker volume
GLOBAL BBU_EAR_VOL ; Ear speaker volume
GLOBAL BBU_CODEC_TONE ; Send tone(s) to codec
GLOBAL BBU_CODEC_MIC ; Route microphone data to the platform speaker
GLOBAL BBU_CODEC_RALS ; Read Ambient Light Sensor test
GLOBAL BBU_CODEC_TBOX ; Report back if a "touch box" was pressed
GLOBAL BBU_CODEC_TCAL ; Calibrate the touch screen
EXTERN BBU_getI2C ; Read from I2C bus
EXTERN BBU_putI2C ; Write to I2C bus
EXTERN BBU_msWait ; Miliseconbd Wait Routine
EXTERN BBU_getchr ; Fetch a character
EXTERN BBU_putchr ; Output a character
EXTERN BBU_putstr ; Output a character string
EXTERN BBU_crlf ; New line
EXTERN BBU_puthexb ; Output a hex byte
EXTERN BBU_GetPhysical ; Virtual to Physical address translator
EXTERN BBU_U32Divide ; Divide routine
EXTERN BBU_LCD_COLOR ; Set the LCD screen color
EXTERN BBU_LCD_put16x20str ; Output character string to LCD
EXTERN BBU_CMD_SW ; Command switch array
EXTERN BBU_CMD_ARG ; Command argument array
EXTERN TBOX_ARR ; Touch box location array data
EXTERN BBU_LCD_TYPE ; LCD type stored here
AREA |text|, CODE, READONLY, ALIGN = 5
;
;*********************************************************************************
;
; ******************
; * *
; * BBU_CODEC_INIT * Subroutine
; * *
; ******************
;
; This subroutine inits the DA9034 Codec for use
;
; PARAMETER PASSING:
;
; INPUT:
;
; r0 = 0 for HIFI (I2S) Codec init
; r0 = 1 for VOICE (PCM) Codec init
;
;
BBU_CODEC_INIT FUNCTION
stmfd sp!, {r0-r4, lr} ; Save used registers
;
; Enable SSP3 Controller Clock
;
ldr r3, =xlli_CLKREGS_PHYSICAL_BASE ; Base address of clock unit
ldr r2, [r3, #xlli_D0CKEN_A_offset] ; Get current setting of clock enable register
orr r2, r2, #0x10000000 ; Set bit 28 (SSP3 Clock Enable)
str r2, [r3, #xlli_D0CKEN_A_offset] ; Write the register back
;
; Send 13MHz clock out to codec
;
ldr r2, =0x41350000 ; OSCC register physical base
ldr r1, [r2] ; fetch value
orr r1, r1, #0x800 ; OR in the PEN bit
str r1, [r2] ; Write the register back
cmp r0, #0 ; Standard (0) or PCM (non-0) setup?
bne %F10 ; PCM setup - skip to this code
;
; HIFI (I2S) SETUP - Configure interface for 3.072 MHz clock, 32-bit data
;
ldr r2, =bbu_SSP3_PHYSICAL_BASE ; Base address for selected SSP port
ldr r4, =0x4010003F ; Standard - Magic number (sorry!!)
str r4, [r2,#bbu_SSCR0_offset] ; Write to control register 0 (disables SSPx)
ldr r4, =0x00A00000 ; Standard - Magic number (clock always running for now)
str r4, [r2,#bbu_SSCR1_offset] ; Write to control register 1
ldr r4, =0x02200400 ; Standard - magic number
str r4, [r2,#bbu_SSPSPx_offset] ; Write the protocol register
mov r4, #0x60 ; Standard - Yet another magic number
str r4, [r2,#bbu_SSACDx_offset] ; Update Audio Clock Divider Register
ldr r4, =0x06590040 ; Standard - Dither divider values
str r4, [r2,#bbu_SSACDDx_offset]; Update the Audio Clock Dither Divider
b %F20 ; Continue setup here
;
; VOICE (PCM) SETUP
;
10 ldr r2, =bbu_SSP4_PHYSICAL_BASE ; Base address for selected SSP port
ldr r4, =0x00C02C3F ; PCM - Magic number (16KHz sample rate)
; ldr r4, =0x00C0583F ; PCM - Magic number (8KHz sample rate)
str r4, [r2,#bbu_SSCR0_offset] ; Write to control register 0 (disables SSPx)
ldr r4, =0x00A01DC0 ; PCM - Magic number
str r4, [r2,#bbu_SSCR1_offset] ; Write to control register 1
ldr r4, =0x00000085 ; PCM - magic number
str r4, [r2,#bbu_SSPSPx_offset] ; Write the protocol register
;
; Set the enable bit
;
20 ldr r4, [r2,#bbu_SSCR0_offset] ; Get contents of control register 0
orr r4, r4, #0x80 ; Set the port enable bit
str r4, [r2,#bbu_SSCR0_offset] ; Write to control register 0
;
; Set the I2C address for the DA9034 audio codec
;
mov r4, #0x68 ; I2C address for PMIC
ldr r0, =bbu_FFUART_PHYSICAL_BASE ; Fetch base address of FFUART
str r4, [r0, #bbu_UASPR_offset] ; Store I2C address in the scratch pad register
;
; Set up some basic Codec features via the I2C bus
;
mov r0, #0x7B ; Register 0x7B (I2S_CONTROL)
mov r1, #0x9F ; Set up I2S controller for 48KHz audio MSB justified
bl BBU_putI2C ; Write out to I2C bus
mov r0, #0x78 ; Register 0x78 (STEREO_DAC_CONTROL)
mov r1, #0x80 ; Enable the DAC
bl BBU_putI2C ; Write out to I2C bus
ldmfd sp!, {r0-r4, pc} ; Return to caller
ENDFUNC
;
;*********************************************************************************
;
; ****************
; * *
; * BBU_TSI_VALU * Subroutine
; * *
; ****************
;
; This subroutine gets the current Touch Screen Interface X, Y and pen status
; values from the DA9034 Codec and returns them to the caller.
;
; PARAMETER PASSING:
;
; INPUT:
; No parameters
;
; OUTPUT:
;
; r0 contains the X value
; r1 contains the Y value
; r2 = 0 for PEN UP, 1 for PEN DOWN, 0xFF for bus time out
;
;
BBU_TSI_VALU FUNCTION
;
stmfd sp!, {r3,lr} ; Save used registers
;
; Set the I2C address for the DA9034 audio codec
;
mov r3, #0x68 ; I2C address for PMIC
ldr r0, =bbu_FFUART_PHYSICAL_BASE ; Fetch base address of FFUART
str r3, [r0, #bbu_UASPR_offset] ; Store I2C address in the scratch pad register
;
; Set up the A/D converter and have auto conversion run on the TSI
;
mov r0, #0x50 ; PMIC register address (Manual Control)
mov r1, #0x10 ; Set the LDO_ADC enable bit
bl BBU_putI2C ; Write to chip
mov r0, #0x52 ; PMIC register address (Auto Control 2)
mov r1, #0x18 ; Set the PEN_DETECT and AUTO_TSI bits
bl BBU_putI2C ; Write to chip
mov r0, #0x54 ; PMIC register address (TSI Control 2)
mov r1, #0x80 ; Set the ADCREF bit
bl BBU_putI2C ; Write to chip
;
; IMPORTANT NOTE: Turning on the AUTO_TSI_ENABLE bit will disable Pen
; detection (and clear the PEN DOWN bit). Sooooooo, BBU turns on the
; AUTO_TSI_ENABLE bit for 40 mS then off for 5 mS and then goes through
; the registers to get the status and update the user. BBU uses polling
; for its TSI test (no interrupts).
;
mov r0, #0x52 ; PMIC register address (AUTO_CONTROL_2)
mov r1, #0x18 ; Set bits to do auto measurement
bl BBU_putI2C ; Write to chip
mov r0, #40 ; set up for r0 millisecond delay
bl BBU_msWait ; Delay
mov r0, #0x52 ; PMIC register address (AUTO_CONTROL_2)
mov r1, #0x10 ; Turn auto measurement OFF
bl BBU_putI2C ; Write to chip
mov r0, #5 ; set up for r0 millisecond delay
bl BBU_msWait ; Delay
;
; Get PEN UP/DOWN value
;
mov r0, #0x6E ; TSI_X+Y_LSB register - to get PEN status
bl BBU_getI2C ; Read from chip
cmp r2, #0 ; Was there a bus timeout?
moveq r2, #0xFF ; Yes - set timout indicator...
beq %F50 ; ...and take the exit path
ands r1, r1, #0x10 ; Is the PEN UP or DOWN?
moveq r0, #0 ; UP - zero out x location
moveq r1, #0 ; UP - zero out Y location
moveq r2, #0 ; Up - zero out Pen Down value
beq %F50 ; and take exit path
;
; If Pen was down - Get X value
;
mov r0, #0x6C ; TSI_X_MSB register (BBU doesn't bother with LSBs)
bl BBU_getI2C ; Read from chip
mov r3, r1 ; copy the value to r3
;
; Get Y value
;
mov r0, #0x6D ; TSI_Y_MSB register (BBU doesn't bother with LSBs)
bl BBU_getI2C ; Read from chip
;
; Copy parameters to return registers
;
mov r0, r3 ; copy saved X position
mov r2, #1 ; Indicate pen is DOWN
50 ldmfd sp!, {r3,pc} ; Return to caller
ENDFUNC
;
;*********************************************************************************
;
; ****************
; * *
; * BBU_TSI_LIFT * Subroutine
; * *
; ****************
;
; This subroutine monitors the Touch Screen Interface until the the pen status
; transistions from a PEN DOWN to a PEN UP condition and then returns the last
; known X and Y postion of the pen to the caller.
;
; PARAMETER PASSING:
;
; INPUT:
; No parameters
;
; OUTPUT:
;
; r0 contains the last known X value
; r1 contains the last known Y value
;
BBU_TSI_LIFT FUNCTION
stmfd sp!, {r2-r4,lr} ; Save used registers
mov r3, #0 ; Clear r3
mov r4, r3 ; Clear r4
;
; This routine work by looking at the last value read when the pen
; was in the DOWN position.
;
170 bl BBU_TSI_VALU ; Fetch values from the touch screen
cmp r2, #0 ; Is the pen UP or DOWN?
beq %F172 ; It's UP, jump to this code
mov r3, r0 ; Save latest X value in r3
mov r4, r1 ; Save latest Y value in r4
b %B170 ; Get another reading
;
; Pen is up. See if the user has touched the screen since this
; subroutine was called.
;
172 cmp r3, #0 ; Anything saved for the X value?
beq %B170 ; Nope - wait until something comes in
mov r0, r3 ; Copy X data to r0
mov r1, r4 ; Copy Y data to r1
ldmfd sp!, {r2-r4,pc} ; Return to caller
ENDFUNC
;
;*********************************************************************************
;
; ****************
; * *
; * BBU_TSI_TEST * Subroutine
; * *
; ****************
;
; This subroutine performs the Touch Screen Interface (TSI) test
;
; PARAMETER PASSING:
;
; No Parameters
;
BBU_TSI_TEST FUNCTION
stmfd sp!, {r0-r5,lr} ; Save used registers
;
mov r5, #7 ; Should be non-zero going into subroutine
;
; Fetch values from TSI
;
631 bl BBU_TSI_VALU ; Get TSI values
mov r3, r0 ; Save off X pos
mov r4, r1 ; Save off Y pos
cmp r2, #0xFF ; Time out error?
beq %F634 ; YES - take this exit path
cmp r2, #0 ; Pen up or down?
ldreq r0, =BBU_TPAN_MSGXU ; Address of PEN UP message
ldrne r0, =BBU_TPAN_MSGXD ; Address of PEN DOWN message
bne %F632 ; If PEN DOWN - skip to 632
cmp r5, #0 ; Was the previous message a PEN UP one?
beq %F363 ; Yes - just check for keyboard input
632 bl BBU_putstr ; NO - Output string
mov r5, r2 ; Copy pen UP/DOWN status to r5
;
; Display X value
;
mov r0, r3 ; Copy X value to r0
bl BBU_puthexb ; Send the byte value out to the user
;
; Display Y value
;
ldr r0, =BBU_TPAN_MSGY ; Address of message prefix
bl BBU_putstr ; Output string
mov r0, r4 ; Copy Y value to r0
bl BBU_puthexb ; Send the byte value out to the user
mov r0, #0xD ; <cr> character
bl BBU_putchr ; Output character
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -