2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 /*******************************************************************************
28 * Audio codec stub file
34 *------------------------------------------------------------------------------
40 *******************************************************************************/
43 /*****************************************************************************
44 * C O M P I L E R F L A G S
45 *****************************************************************************/
48 /*****************************************************************************
49 * E X T E R N A L R E F E R E N C E S
50 *****************************************************************************/
52 #include <linux/dma-mapping.h>
53 #include <linux/platform_device.h>
54 #include <linux/slab.h>
55 #include <linux/module.h>
56 #include <linux/of_device.h>
57 #include <sound/core.h>
58 #include <sound/pcm.h>
59 #include <sound/soc.h>
60 #include <mach/mt_gpio.h>
62 #include "AudDrv_Common.h"
63 #include "AudDrv_Def.h"
64 #include "AudDrv_Afe.h"
65 #include "AudDrv_Ana.h"
66 #include "AudDrv_Clk.h"
67 #include "mt_soc_analog_type.h"
68 #include <mach/mt_clkbuf_ctl.h>
69 #include <mach/mt_chip.h>
70 #include <sound/mt_soc_audio.h>
71 #include <mach/vow_api.h>
72 #include "mt_soc_afe_control.h"
73 #include <mach/upmu_common_sw.h>
74 #include <mach/upmu_hw.h>
75 #include <mach/mt_pmic_wrap.h>
77 #ifdef CONFIG_MTK_SPEAKER
78 #include "mt_soc_codec_speaker_63xx.h"
79 #include <cust_pmic.h>
80 int PMIC_IMM_GetOneChannelValue(int dwChannel
, int deCount
, int trimd
);
83 #include "mt_soc_pcm_common.h"
85 #define AW8736_MODE_CTRL // AW8736 PA output power mode control
87 // static function declaration
88 static bool AudioPreAmp1_Sel(int Mul_Sel
);
89 static bool GetAdcStatus(void);
90 static void Apply_Speaker_Gain(void);
91 static bool TurnOnVOWDigitalHW(bool enable
);
92 static void TurnOffDacPower(void);
93 static void TurnOnDacPower(void);
94 static void SetDcCompenSation(void);
95 static void Voice_Amp_Change(bool enable
);
96 static void Speaker_Amp_Change(bool enable
);
97 static bool TurnOnVOWADcPowerACC(int MicType
, bool enable
);
99 extern int PMIC_IMM_GetOneChannelValue(int dwChannel
, int deCount
, int trimd
);
101 static mt6331_Codec_Data_Priv
*mCodec_data
= NULL
;
102 static uint32 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_INOUT_MAX
] = {48000, 48000, 48000};
103 static DEFINE_MUTEX(Ana_Ctrl_Mutex
);
104 static DEFINE_MUTEX(Ana_buf_Ctrl_Mutex
);
105 static DEFINE_MUTEX(Ana_Clk_Mutex
);
106 static DEFINE_MUTEX(Ana_Power_Mutex
);
107 static DEFINE_MUTEX(AudAna_lock
);
109 static int mAudio_Analog_Mic1_mode
= AUDIO_ANALOGUL_MODE_ACC
;
110 static int mAudio_Analog_Mic2_mode
= AUDIO_ANALOGUL_MODE_ACC
;
111 static int mAudio_Analog_Mic3_mode
= AUDIO_ANALOGUL_MODE_ACC
;
112 static int mAudio_Analog_Mic4_mode
= AUDIO_ANALOGUL_MODE_ACC
;
114 static int mAudio_Vow_Analog_Func_Enable
= false;
115 static int mAudio_Vow_Digital_Func_Enable
= false;
117 static int TrimOffset
= 2048;
118 static const int DC1unit_in_uv
= 19184; // in uv with 0DB
119 static const int DC1devider
= 8; // in uv
121 static uint32 RG_AUDHPLTRIM_VAUDP15
, RG_AUDHPRTRIM_VAUDP15
, RG_AUDHPLFINETRIM_VAUDP15
, RG_AUDHPRFINETRIM_VAUDP15
,
122 RG_AUDHPLTRIM_VAUDP15_SPKHP
, RG_AUDHPRTRIM_VAUDP15_SPKHP
, RG_AUDHPLFINETRIM_VAUDP15_SPKHP
, RG_AUDHPRFINETRIM_VAUDP15_SPKHP
;
124 #ifdef CONFIG_MTK_SPEAKER
125 static int Speaker_mode
= AUDIO_SPEAKER_MODE_AB
;
126 static unsigned int Speaker_pga_gain
= 1 ; // default 0Db.
127 static bool mSpeaker_Ocflag
= false;
129 static int mAdc_Power_Mode
= 0;
130 static unsigned int dAuxAdcChannel
= 16;
131 static const int mDcOffsetTrimChannel
= 9;
132 static bool mInitCodec
= false;
134 static uint32 MicbiasRef
, GetMicbias
;
136 static int reg_AFE_VOW_CFG0
= 0x0000; //VOW AMPREF Setting
137 static int reg_AFE_VOW_CFG1
= 0x0000; //VOW A,B timeout initial value (timer)
138 static int reg_AFE_VOW_CFG2
= 0x2222; //VOW A,B value setting (BABA)
139 static int reg_AFE_VOW_CFG3
= 0x8767; //alhpa and beta K value setting (beta_rise,fall,alpha_rise,fall)
140 static int reg_AFE_VOW_CFG4
= 0x006E; //gamma K value setting (gamma), bit4:8 should not modify
141 static int reg_AFE_VOW_CFG5
= 0x0001; //N mini value setting (Nmin)
142 static bool mIsVOWOn
= false;
147 AUDIO_VOW_MIC_TYPE_Handset_AMIC
= 0,
148 AUDIO_VOW_MIC_TYPE_Headset_MIC
,
149 AUDIO_VOW_MIC_TYPE_Handset_DMIC
, //1P6
150 AUDIO_VOW_MIC_TYPE_Handset_DMIC_800K
, //800K
151 AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCC
, //DCC mems
152 AUDIO_VOW_MIC_TYPE_Headset_MIC_DCC
,
153 AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCCECM
, //DCC ECM, dual differential
154 AUDIO_VOW_MIC_TYPE_Headset_MIC_DCCECM
//DCC ECM, signal differential
155 } AUDIO_VOW_MIC_TYPE
;
157 static int mAudio_VOW_Mic_type
= AUDIO_VOW_MIC_TYPE_Handset_AMIC
;
158 static void Audio_Amp_Change(int channels
, bool enable
);
159 static void SavePowerState(void)
162 for (i
= 0; i
< AUDIO_ANALOG_DEVICE_MAX
; i
++)
164 mCodec_data
->mAudio_BackUpAna_DevicePower
[i
] = mCodec_data
->mAudio_Ana_DevicePower
[i
];
168 static void RestorePowerState(void)
171 for (i
= 0; i
< AUDIO_ANALOG_DEVICE_MAX
; i
++)
173 mCodec_data
->mAudio_Ana_DevicePower
[i
] = mCodec_data
->mAudio_BackUpAna_DevicePower
[i
];
177 static bool GetDLStatus(void)
180 for (i
= 0; i
< AUDIO_ANALOG_DEVICE_2IN1_SPK
; i
++)
182 if (mCodec_data
->mAudio_Ana_DevicePower
[i
] == true)
190 static bool mAnaSuspend
= false;
191 void SetAnalogSuspend(bool bEnable
)
193 printk("%s bEnable ==%d mAnaSuspend = %d \n", __func__
, bEnable
, mAnaSuspend
);
194 if ((bEnable
== true) && (mAnaSuspend
== false))
198 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == true)
200 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = false;
201 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, false);
203 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == true)
205 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = false;
206 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, false);
208 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] == true)
210 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] = false;
211 Voice_Amp_Change(false);
213 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] == true)
215 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] = false;
216 Speaker_Amp_Change(false);
221 else if ((bEnable
== false) && (mAnaSuspend
== true))
224 if (mCodec_data
->mAudio_BackUpAna_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == true)
226 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, true);
227 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = true;
229 if (mCodec_data
->mAudio_BackUpAna_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == true)
231 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, true);
232 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = false;
234 if (mCodec_data
->mAudio_BackUpAna_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] == true)
236 Voice_Amp_Change(true);
237 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] = false;
239 if (mCodec_data
->mAudio_BackUpAna_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] == true)
241 Speaker_Amp_Change(true);
242 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] = false;
250 static int audck_buf_Count
= 0;
251 void audckbufEnable(bool enable
)
253 printk("audckbufEnable audck_buf_Count = %d enable = %d \n", audck_buf_Count
, enable
);
254 mutex_lock(&Ana_buf_Ctrl_Mutex
);
257 if (audck_buf_Count
== 0)
259 printk("+clk_buf_ctrl(CLK_BUF_AUDIO,true)\n");
260 clk_buf_ctrl(CLK_BUF_AUDIO
, true);
261 printk("-clk_buf_ctrl(CLK_BUF_AUDIO,true)\n");
268 if (audck_buf_Count
== 0)
270 printk("+clk_buf_ctrl(CLK_BUF_AUDIO,false)\n");
271 clk_buf_ctrl(CLK_BUF_AUDIO
, false);
272 printk("-clk_buf_ctrl(CLK_BUF_AUDIO,false)\n");
274 if (audck_buf_Count
< 0)
276 printk("audck_buf_Count count <0 \n");
280 mutex_unlock(&Ana_buf_Ctrl_Mutex
);
283 static int ClsqCount
= 0;
284 static void ClsqEnable(bool enable
)
286 printk("ClsqEnable ClsqCount = %d enable = %d \n", ClsqCount
, enable
);
287 mutex_lock(& AudAna_lock
);
292 Ana_Set_Reg(TOP_CLKSQ
, 0x0001, 0x0001); //Enable CLKSQ 26MHz
293 Ana_Set_Reg(TOP_CLKSQ_SET
, 0x0001, 0x0001); //Turn on 26MHz source clock
302 printk("ClsqEnable count <0 \n");
307 Ana_Set_Reg(TOP_CLKSQ_CLR
, 0x0001, 0x0001); //Turn off 26MHz source clock
308 Ana_Set_Reg(TOP_CLKSQ
, 0x0000, 0x0001); //Disable CLKSQ 26MHz
311 mutex_unlock(& AudAna_lock
);
314 static int TopCkCount
= 0;
315 static void Topck_Enable(bool enable
)
317 printk("Topck_Enable enable = %d TopCkCount = %d \n", enable
, TopCkCount
);
318 mutex_lock(&Ana_Clk_Mutex
);
323 Ana_Set_Reg(TOP_CKPDN_CON0_CLR
, 0x3800, 0x3800); //Turn on AUDNCP_CLKDIV engine clock,Turn on AUD 26M
332 Ana_Set_Reg(TOP_CKPDN_CON0_SET
, 0x3800, 0x3800); //Turn off AUDNCP_CLKDIV engine clock,Turn off AUD 26M
336 printk("TopCkCount <0 =%d\n ", TopCkCount
);
340 mutex_unlock(&Ana_Clk_Mutex
);
343 static int NvRegCount
= 0;
344 static void NvregEnable(bool enable
)
346 printk("NvregEnable NvRegCount == %d enable = %d \n", NvRegCount
, enable
);
347 mutex_lock(&Ana_Clk_Mutex
);
352 Ana_Set_Reg(AUDDEC_ANA_CON8
, 0x0000, 0x0002); // Enable AUDGLB
361 Ana_Set_Reg(AUDDEC_ANA_CON8
, 0x0002, 0x0002); // disable AUDGLB
365 printk("NvRegCount <0 =%d\n ", NvRegCount
);
369 mutex_unlock(&Ana_Clk_Mutex
);
372 static int VOW12MCKCount
= 0;
373 static void VOW12MCK_Enable(bool enable
)
375 printk("VOW12MCK_Enable VOW12MCKCount == %d enable = %d \n", VOW12MCKCount
, enable
);
376 mutex_lock(&Ana_Clk_Mutex
);
379 if (VOW12MCKCount
== 0)
381 Ana_Set_Reg(TOP_CKPDN_CON0_CLR
, 0x8000, 0x8000); // Enable TOP_CKPDN_CON0 bit15 for enable VOW 12M clock
388 if (VOW12MCKCount
== 0)
390 Ana_Set_Reg(TOP_CKPDN_CON0_SET
, 0x8000, 0x8000); // disable TOP_CKPDN_CON0 bit15 for enable VOW 12M clock
392 if (VOW12MCKCount
< 0)
394 printk("VOW12MCKCount <0 =%d\n ", VOW12MCKCount
);
398 mutex_unlock(&Ana_Clk_Mutex
);
401 void vow_irq_handler(void)
403 printk("vow_irq_handler,audio irq event....\n");
404 //TurnOnVOWADcPowerACC(AUDIO_ANALOG_DEVICE_IN_ADC1, false);
405 //TurnOnVOWDigitalHW(false);
406 #if defined(VOW_TONE_TEST)
407 EnableSideGenHw(Soc_Aud_InterConnectionOutput_O03
, Soc_Aud_MemIF_Direction_DIRECTION_OUTPUT
, true);
409 //VowDrv_ChangeStatus();
412 extern kal_uint32
upmu_get_reg_value(kal_uint32 reg
);
414 void Auddrv_Read_Efuse_HPOffset(void)
421 printk("Auddrv_Read_Efuse_HPOffset(+)\n");
423 //1. enable efuse ctrl engine clock
424 ret
= pmic_config_interface(0x026C, 0x0040, 0xFFFF, 0);
425 ret
= pmic_config_interface(0x024E, 0x0004, 0xFFFF, 0);
428 ret
= pmic_config_interface(0x0C16, 0x1, 0x1, 0);
431 Audio data from 746 to 770
437 for (i
= 0xe; i
<= 0x10; i
++)
440 ret
= pmic_config_interface(0x0C00, i
, 0x1F, 1);
443 ret
= pmic_read_interface(0xC10, ®_val
, 0x1, 0);
446 ret
= pmic_config_interface(0xC10, 1, 0x1, 0);
450 ret
= pmic_config_interface(0xC10, 0, 0x1, 0);
453 //5. polling Reg[0xC1A]
457 ret
= pmic_read_interface(0xC1A, ®_val
, 0x1, 0);
458 printk("Auddrv_Read_Efuse_HPOffset polling 0xC1A=0x%x\n", reg_val
);
461 udelay(1000);//Need to delay at least 1ms for 0xC1A and than can read 0xC18
464 efusevalue
[j
] = upmu_get_reg_value(0x0C18);
465 printk("HPoffset : efuse[%d]=0x%x\n", j
, efusevalue
[j
]);
469 //7. Disable efuse ctrl engine clock
470 ret
= pmic_config_interface(0x024C, 0x0004, 0xFFFF, 0);
471 ret
= pmic_config_interface(0x026A, 0x0040, 0xFFFF, 0);
473 RG_AUDHPLTRIM_VAUDP15
= (efusevalue
[0] >> 10) & 0xf;
474 RG_AUDHPRTRIM_VAUDP15
= ((efusevalue
[0] >> 14) & 0x3) + ((efusevalue
[1] & 0x3) << 2);
475 RG_AUDHPLFINETRIM_VAUDP15
= (efusevalue
[1] >> 3) & 0x3;
476 RG_AUDHPRFINETRIM_VAUDP15
= (efusevalue
[1] >> 5) & 0x3;
477 RG_AUDHPLTRIM_VAUDP15_SPKHP
= (efusevalue
[1] >> 7) & 0xF;
478 RG_AUDHPRTRIM_VAUDP15_SPKHP
= (efusevalue
[1] >> 11) & 0xF;
479 RG_AUDHPLFINETRIM_VAUDP15_SPKHP
= ((efusevalue
[1] >> 15) & 0x1) + ((efusevalue
[2] & 0x1) << 1);
480 RG_AUDHPRFINETRIM_VAUDP15_SPKHP
= ((efusevalue
[2] >> 1) & 0x3);
482 printk("RG_AUDHPLTRIM_VAUDP15 = %x\n", RG_AUDHPLTRIM_VAUDP15
);
483 printk("RG_AUDHPRTRIM_VAUDP15 = %x\n", RG_AUDHPRTRIM_VAUDP15
);
484 printk("RG_AUDHPLFINETRIM_VAUDP15 = %x\n", RG_AUDHPLFINETRIM_VAUDP15
);
485 printk("RG_AUDHPRFINETRIM_VAUDP15 = %x\n", RG_AUDHPRFINETRIM_VAUDP15
);
486 printk("RG_AUDHPLTRIM_VAUDP15_SPKHP = %x\n", RG_AUDHPLTRIM_VAUDP15_SPKHP
);
487 printk("RG_AUDHPRTRIM_VAUDP15_SPKHP = %x\n", RG_AUDHPRTRIM_VAUDP15_SPKHP
);
488 printk("RG_AUDHPLFINETRIM_VAUDP15_SPKHP = %x\n", RG_AUDHPLFINETRIM_VAUDP15_SPKHP
);
489 printk("RG_AUDHPRFINETRIM_VAUDP15_SPKHP = %x\n", RG_AUDHPRFINETRIM_VAUDP15_SPKHP
);
491 printk("Auddrv_Read_Efuse_HPOffset(-)\n");
494 EXPORT_SYMBOL(Auddrv_Read_Efuse_HPOffset
);
496 #ifdef CONFIG_MTK_SPEAKER
497 static void Apply_Speaker_Gain(void)
499 printk("%s Speaker_pga_gain= %d\n", __func__
, Speaker_pga_gain
);
501 Ana_Set_Reg(SPK_ANA_CON0
, Speaker_pga_gain
<< 11, 0x7800);
504 static void Apply_Speaker_Gain(void)
510 void setOffsetTrimMux(unsigned int Mux
)
512 printk("%s Mux = %d\n", __func__
, Mux
);
513 Ana_Set_Reg(AUDDEC_ANA_CON3
, Mux
<< 1, 0xf << 1); // Audio offset trimming buffer mux selection
516 void setOffsetTrimBufferGain(unsigned int gain
)
518 Ana_Set_Reg(AUDDEC_ANA_CON3
, gain
<< 5, 0x3 << 5); // Audio offset trimming buffer gain selection
521 static int mHplTrimOffset
= 2048;
522 static int mHprTrimOffset
= 2048;
524 void SetHplTrimOffset(int Offset
)
526 printk("%s Offset = %d\n", __func__
, Offset
);
527 mHplTrimOffset
= Offset
;
528 if ((Offset
> 2098) || (Offset
< 1998))
530 mHplTrimOffset
= 2048;
531 printk("SetHplTrimOffset offset may be invalid offset = %d\n", Offset
);
535 void SetHprTrimOffset(int Offset
)
537 printk("%s Offset = %d\n", __func__
, Offset
);
538 mHprTrimOffset
= Offset
;
539 if ((Offset
> 2098) || (Offset
< 1998))
541 mHprTrimOffset
= 2048;
542 printk("SetHprTrimOffset offset may be invalid offset = %d\n", Offset
);
546 void EnableTrimbuffer(bool benable
)
550 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x1, 0x1); // Audio offset trimming buffer enable
554 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x0, 0x1); // Audio offset trimming buffer disable
559 void OpenTrimBufferHardware(bool enable
) //0804 TODO!!!
563 printk("%s true\n", __func__
);
565 //set analog part (HP playback)
566 Ana_Set_Reg(AUDDEC_ANA_CON8
, 0x0000, 0x0002); // Enable AUDGLB
567 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
568 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
569 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
570 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
571 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
572 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V) & LDO VA33REFGEN
573 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
574 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
575 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
576 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE080, 0xffff); //Disable headphone, voice and short-ckt protection. voice MUX is set mute
577 //Ana_Set_Reg(AUDDEC_ANA_CON7, 0x, 0xffff); // Enable AU_REFN short circuit //6325 TRIM no need set AU_REFN
579 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
580 //Ana_Set_Reg(AUDDEC_ANA_CON4, 0x0700, 0xffff); //Enable HP & HS drivers bias circuit
581 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x1f00, 0xffff); //Enable HP & HS drivers bias circuit //trim
583 Ana_Set_Reg(AUDDEC_ANA_CON5
, 0x5490, 0xffff); //HP/HS ibias & DR bias current optimization
585 Ana_Set_Reg(ZCD_CON2
, 0x0489, 0xffff); //Set HPR/HPL gain as -1dB
586 Ana_Set_Reg(ZCD_CON3
, 0x001F, 0xffff); //Set voice gain as minimum (~ -40dB)
587 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //De_OSC of HP and enable output STBENH
588 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //De_OSC of voice, enable output STBENH
589 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE090, 0xffff); //Enable voice driver
590 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x14A0, 0xffff); //Enable pre-charge buffer
592 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
593 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0009, 0x0009); //Enable Audio DACL
594 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0006, 0x0006); //Enable Audio DACR
599 printk("%s false\n", __func__
);
600 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
601 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
602 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
603 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
604 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
609 void OpenAnalogTrimHardware(bool enable
)
613 printk("%s true\n", __func__
);
615 //set analog part (HP playback)
616 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
617 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
618 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
619 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
620 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
621 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V) & LDO VA33REFGEN
622 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
623 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
624 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
625 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE080, 0xffff); //Disable headphone, voice and short-ckt protection. voice MUX is set mute
626 //Ana_Set_Reg(AUDDEC_ANA_CON7, 0x, 0xffff); // Enable AU_REFN short circuit //6325 TRIM no need set AU_REFN
628 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
629 //Ana_Set_Reg(AUDDEC_ANA_CON4, 0x0700, 0xffff); //Enable HP & HS drivers bias circuit
630 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x1f00, 0xffff); //Enable HP & HS drivers bias circuit //trim
632 Ana_Set_Reg(AUDDEC_ANA_CON5
, 0x5490, 0xffff); //HP/HS ibias & DR bias current optimization
634 Ana_Set_Reg(ZCD_CON2
, 0x0489, 0xffff); //Set HPR/HPL gain as -1dB
635 Ana_Set_Reg(ZCD_CON3
, 0x001F, 0xffff); //Set voice gain as minimum (~ -40dB)
636 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //De_OSC of HP and enable output STBENH
637 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //De_OSC of voice, enable output STBENH
638 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE090, 0xffff); //Enable voice driver
639 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x14A0, 0xffff); //Enable pre-charge buffer
641 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
642 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0009, 0x0009); //Enable Audio DACL
643 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0006, 0x0006); //Enable Audio DACR
648 printk("%s false\n", __func__
);
649 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
650 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
651 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
652 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
653 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
658 void OpenAnalogHeadphone(bool bEnable
)
660 printk("OpenAnalogHeadphone bEnable = %d", bEnable
);
663 SetHplTrimOffset(2048);
664 SetHprTrimOffset(2048);
665 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_OUT_DAC
] = 44100;
666 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, true);
667 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = true;
668 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, true);
669 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = true;
673 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = false;
674 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, false);
675 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = false;
676 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, false);
680 bool OpenHeadPhoneImpedanceSetting(bool bEnable
)
682 printk("%s benable = %d\n", __func__
, bEnable
);
683 if (GetDLStatus() == true)
691 //set analog part (HP playback)
692 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
693 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
694 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
695 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
696 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
698 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0300, 0xffff); //Enable HP driver bias circuit
700 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V) & LDO VA33REFGEN
701 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
702 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
703 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
704 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE000, 0xffff); //Disable headphone, voice and short-ckt protection. HP and voice MUX is opened
705 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0000, 0xffff); //no De_OSC of HP and disable output STBENH
706 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x0080, 0xffff); //Audio headphone speaker detection enable
707 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
708 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
709 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE009, 0xffff); //Enable Audio DAC
710 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x0900, 0x0f00); //Audio headphone speaker detection output mux selection:(10)HPR, Audio headphone speaker detection input mux enable:(01)DACLP
714 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
715 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
716 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
717 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
718 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
719 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x0000, 0x0080); //Audio headphone speaker detection disable
720 Ana_Set_Reg(AUDDEC_ANA_CON3
, 0x0000, 0x0f00); //output mux selection:(00)OPEN, input mux selection:(00)OPEN,
726 void setHpGainZero(void)
728 Ana_Set_Reg(ZCD_CON2
, 0x8 << 7, 0x0f80);
729 Ana_Set_Reg(ZCD_CON2
, 0x8 , 0x001f);
732 void SetSdmLevel(unsigned int level
)
734 Ana_Set_Reg(AFE_DL_SDM_CON1
, level
, 0xffffffff);
738 static void SetHprOffset(int OffsetTrimming
)
740 short Dccompsentation
= 0;
741 int DCoffsetValue
= 0;
742 unsigned short RegValue
= 0;
743 printk("%s OffsetTrimming = %d \n", __func__
, OffsetTrimming
);
744 DCoffsetValue
= OffsetTrimming
* 1000000;
745 DCoffsetValue
= (DCoffsetValue
/ DC1devider
); // in uv
746 printk("%s DCoffsetValue = %d \n", __func__
, DCoffsetValue
);
747 DCoffsetValue
= (DCoffsetValue
/ DC1unit_in_uv
);
748 printk("%s DCoffsetValue = %d \n", __func__
, DCoffsetValue
);
749 Dccompsentation
= DCoffsetValue
;
750 RegValue
= Dccompsentation
;
751 printk("%s RegValue = 0x%x\n", __func__
, RegValue
);
752 Ana_Set_Reg(AFE_DL_DC_COMP_CFG1
, RegValue
, 0xffff);
755 static void SetHplOffset(int OffsetTrimming
)
757 short Dccompsentation
= 0;
758 int DCoffsetValue
= 0;
759 unsigned short RegValue
= 0;
760 printk("%s OffsetTrimming = %d \n", __func__
, OffsetTrimming
);
761 DCoffsetValue
= OffsetTrimming
* 1000000;
762 DCoffsetValue
= (DCoffsetValue
/ DC1devider
); // in uv
763 printk("%s DCoffsetValue = %d \n", __func__
, DCoffsetValue
);
764 DCoffsetValue
= (DCoffsetValue
/ DC1unit_in_uv
);
765 printk("%s DCoffsetValue = %d \n", __func__
, DCoffsetValue
);
766 Dccompsentation
= DCoffsetValue
;
767 RegValue
= Dccompsentation
;
768 printk("%s RegValue = 0x%x\n", __func__
, RegValue
);
769 Ana_Set_Reg(AFE_DL_DC_COMP_CFG0
, RegValue
, 0xffff);
772 static void EnableDcCompensation(bool bEnable
)
774 #ifndef EFUSE_HP_TRIM
775 Ana_Set_Reg(AFE_DL_DC_COMP_CFG2
, bEnable
, 0x1);
779 static void SetHprOffsetTrim(void)
781 int OffsetTrimming
= mHprTrimOffset
- TrimOffset
;
782 printk("%s mHprTrimOffset = %d TrimOffset = %d \n", __func__
, mHprTrimOffset
, TrimOffset
);
783 SetHprOffset(OffsetTrimming
);
786 static void SetHpLOffsetTrim(void)
788 int OffsetTrimming
= mHplTrimOffset
- TrimOffset
;
789 printk("%s mHprTrimOffset = %d TrimOffset = %d \n", __func__
, mHplTrimOffset
, TrimOffset
);
790 SetHplOffset(OffsetTrimming
);
793 static void SetDcCompenSation(void)
795 #ifndef EFUSE_HP_TRIM
798 EnableDcCompensation(true);
799 #else //use efuse trim
800 Ana_Set_Reg(AUDDEC_ANA_CON2
, 0x0800, 0x0800); //Enable trim circuit of HP
801 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPLTRIM_VAUDP15
<< 3, 0x0078); //Trim offset voltage of HPL
802 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPRTRIM_VAUDP15
<< 7, 0x0780); //Trim offset voltage of HPR
803 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPLFINETRIM_VAUDP15
<< 12, 0x3000); //Fine trim offset voltage of HPL
804 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPRFINETRIM_VAUDP15
<< 14, 0xC000); //Fine trim offset voltage of HPR
808 static void SetDcCompenSation_SPKHP(void)
810 #ifdef EFUSE_HP_TRIM //use efuse trim
811 Ana_Set_Reg(AUDDEC_ANA_CON2
, 0x0800, 0x0800); //Enable trim circuit of HP
812 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPLTRIM_VAUDP15_SPKHP
<< 3, 0x0078); //Trim offset voltage of HPL
813 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPRTRIM_VAUDP15_SPKHP
<< 7, 0x0780); //Trim offset voltage of HPR
814 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPLFINETRIM_VAUDP15_SPKHP
<< 12, 0x3000); //Fine trim offset voltage of HPL
815 Ana_Set_Reg(AUDDEC_ANA_CON2
, RG_AUDHPRFINETRIM_VAUDP15_SPKHP
<< 14, 0xC000); //Fine trim offset voltage of HPR
820 static void SetDCcoupleNP(int MicBias
, int mode
)
822 printk("%s MicBias= %d mode = %d\n", __func__
, MicBias
, mode
);
825 case AUDIO_ANALOGUL_MODE_ACC
:
826 case AUDIO_ANALOGUL_MODE_DCC
:
827 case AUDIO_ANALOGUL_MODE_DMIC
:
829 if (MicBias
== AUDIO_MIC_BIAS0
)
831 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0000, 0x0006);
833 else if (MicBias
== AUDIO_MIC_BIAS1
)
835 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0000, 0x0060);
839 case AUDIO_ANALOGUL_MODE_DCCECMDIFF
:
841 if (MicBias
== AUDIO_MIC_BIAS0
)
843 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0006, 0x0006);
845 else if (MicBias
== AUDIO_MIC_BIAS1
)
847 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0060, 0x0060);
851 case AUDIO_ANALOGUL_MODE_DCCECMSINGLE
:
853 if (MicBias
== AUDIO_MIC_BIAS0
)
855 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0002, 0x0006);
857 else if (MicBias
== AUDIO_MIC_BIAS1
)
859 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0020, 0x0060);
868 uint32
GetULFrequency(uint32 frequency
)
870 uint32 Reg_value
= 0;
871 printk("%s frequency =%d\n", __func__
, frequency
);
889 uint32
ULSampleRateTransform(uint32 SampleRate
)
908 static int mt63xx_codec_startup(struct snd_pcm_substream
*substream
, struct snd_soc_dai
*Daiport
)
910 //printk("+mt63xx_codec_startup name = %s number = %d\n", substream->name, substream->number);
911 if (substream
->stream
== SNDRV_PCM_STREAM_CAPTURE
&& substream
->runtime
->rate
)
913 //printk("mt63xx_codec_startup set up SNDRV_PCM_STREAM_CAPTURE rate = %d\n", substream->runtime->rate);
914 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
] = substream
->runtime
->rate
;
917 else if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
&& substream
->runtime
->rate
)
919 //printk("mt63xx_codec_startup set up SNDRV_PCM_STREAM_PLAYBACK rate = %d\n", substream->runtime->rate);
920 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_OUT_DAC
] = substream
->runtime
->rate
;
922 //printk("-mt63xx_codec_startup name = %s number = %d\n", substream->name, substream->number);
926 static int mt63xx_codec_prepare(struct snd_pcm_substream
*substream
, struct snd_soc_dai
*Daiport
)
928 if (substream
->stream
== SNDRV_PCM_STREAM_CAPTURE
)
930 printk("mt63xx_codec_prepare set up SNDRV_PCM_STREAM_CAPTURE rate = %d\n", substream
->runtime
->rate
);
931 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
] = substream
->runtime
->rate
;
934 else if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
936 printk("mt63xx_codec_prepare set up SNDRV_PCM_STREAM_PLAYBACK rate = %d\n", substream
->runtime
->rate
);
937 mBlockSampleRate
[AUDIO_ANALOG_DEVICE_OUT_DAC
] = substream
->runtime
->rate
;
942 static int mt6323_codec_trigger(struct snd_pcm_substream
*substream
, int command
, struct snd_soc_dai
*Daiport
)
946 case SNDRV_PCM_TRIGGER_START
:
947 case SNDRV_PCM_TRIGGER_RESUME
:
948 case SNDRV_PCM_TRIGGER_STOP
:
949 case SNDRV_PCM_TRIGGER_SUSPEND
:
953 //printk("mt6323_codec_trigger command = %d\n ", command);
957 static const struct snd_soc_dai_ops mt6323_aif1_dai_ops
=
959 .startup
= mt63xx_codec_startup
,
960 .prepare
= mt63xx_codec_prepare
,
961 .trigger
= mt6323_codec_trigger
,
964 static struct snd_soc_dai_driver mtk_6331_dai_codecs
[] =
967 .name
= MT_SOC_CODEC_TXDAI_NAME
,
968 .ops
= &mt6323_aif1_dai_ops
,
970 .stream_name
= MT_SOC_DL1_STREAM_NAME
,
973 .rates
= SNDRV_PCM_RATE_8000_192000
,
974 .formats
= SND_SOC_ADV_MT_FMTS
,
978 .name
= MT_SOC_CODEC_RXDAI_NAME
,
979 .ops
= &mt6323_aif1_dai_ops
,
981 .stream_name
= MT_SOC_UL1_STREAM_NAME
,
984 .rates
= SNDRV_PCM_RATE_8000_192000
,
985 .formats
= SND_SOC_ADV_MT_FMTS
,
989 .name
= MT_SOC_CODEC_TDMRX_DAI_NAME
,
990 .ops
= &mt6323_aif1_dai_ops
,
992 .stream_name
= MT_SOC_TDM_CAPTURE_STREAM_NAME
,
995 .rates
= SNDRV_PCM_RATE_8000_192000
,
996 .formats
= (SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S8
|
997 SNDRV_PCM_FMTBIT_U16_LE
| SNDRV_PCM_FMTBIT_S16_LE
|
998 SNDRV_PCM_FMTBIT_U16_BE
| SNDRV_PCM_FMTBIT_S16_BE
|
999 SNDRV_PCM_FMTBIT_U24_LE
| SNDRV_PCM_FMTBIT_S24_LE
|
1000 SNDRV_PCM_FMTBIT_U24_BE
| SNDRV_PCM_FMTBIT_S24_BE
|
1001 SNDRV_PCM_FMTBIT_U24_3LE
| SNDRV_PCM_FMTBIT_S24_3LE
|
1002 SNDRV_PCM_FMTBIT_U24_3BE
| SNDRV_PCM_FMTBIT_S24_3BE
|
1003 SNDRV_PCM_FMTBIT_U32_LE
| SNDRV_PCM_FMTBIT_S32_LE
|
1004 SNDRV_PCM_FMTBIT_U32_BE
| SNDRV_PCM_FMTBIT_S32_BE
),
1008 .name
= MT_SOC_CODEC_I2S0TXDAI_NAME
,
1009 .ops
= &mt6323_aif1_dai_ops
,
1011 .stream_name
= MT_SOC_I2SDL1_STREAM_NAME
,
1016 .rates
= SNDRV_PCM_RATE_8000_192000
,
1017 .formats
= SND_SOC_ADV_MT_FMTS
,
1021 .name
= MT_SOC_CODEC_VOICE_MD1DAI_NAME
,
1022 .ops
= &mt6323_aif1_dai_ops
,
1024 .stream_name
= MT_SOC_VOICE_MD1_STREAM_NAME
,
1027 .rates
= SNDRV_PCM_RATE_8000_48000
,
1028 .formats
= SND_SOC_ADV_MT_FMTS
,
1031 .stream_name
= MT_SOC_VOICE_MD1_STREAM_NAME
,
1034 .rates
= SNDRV_PCM_RATE_8000_48000
,
1035 .formats
= SND_SOC_ADV_MT_FMTS
,
1039 .name
= MT_SOC_CODEC_VOICE_MD2DAI_NAME
,
1040 .ops
= &mt6323_aif1_dai_ops
,
1042 .stream_name
= MT_SOC_VOICE_MD2_STREAM_NAME
,
1045 .rates
= SNDRV_PCM_RATE_8000_48000
,
1046 .formats
= SND_SOC_ADV_MT_FMTS
,
1049 .stream_name
= MT_SOC_VOICE_MD2_STREAM_NAME
,
1052 .rates
= SNDRV_PCM_RATE_8000_48000
,
1053 .formats
= SND_SOC_ADV_MT_FMTS
,
1057 .name
= MT_SOC_CODEC_FMI2S2RXDAI_NAME
,
1058 .ops
= &mt6323_aif1_dai_ops
,
1060 .stream_name
= MT_SOC_FM_I2S2_STREAM_NAME
,
1063 .rates
= SNDRV_PCM_RATE_8000_48000
,
1064 .formats
= SND_SOC_ADV_MT_FMTS
,
1067 .stream_name
= MT_SOC_FM_I2S2_RECORD_STREAM_NAME
,
1070 .rates
= SNDRV_PCM_RATE_8000_48000
,
1071 .formats
= SND_SOC_ADV_MT_FMTS
,
1075 .name
= MT_SOC_CODEC_FMMRGTXDAI_DUMMY_DAI_NAME
,
1076 .ops
= &mt6323_aif1_dai_ops
,
1078 .stream_name
= MT_SOC_FM_MRGTX_STREAM_NAME
,
1081 .rates
= SNDRV_PCM_RATE_8000_48000
,
1082 .formats
= SND_SOC_ADV_MT_FMTS
,
1086 .name
= MT_SOC_CODEC_ULDLLOOPBACK_NAME
,
1087 .ops
= &mt6323_aif1_dai_ops
,
1089 .stream_name
= MT_SOC_ULDLLOOPBACK_STREAM_NAME
,
1092 .rates
= SNDRV_PCM_RATE_8000_48000
,
1093 .formats
= SND_SOC_ADV_MT_FMTS
,
1096 .stream_name
= MT_SOC_ULDLLOOPBACK_STREAM_NAME
,
1099 .rates
= SNDRV_PCM_RATE_8000_48000
,
1100 .formats
= SND_SOC_ADV_MT_FMTS
,
1104 .name
= MT_SOC_CODEC_STUB_NAME
,
1105 .ops
= &mt6323_aif1_dai_ops
,
1107 .stream_name
= MT_SOC_ROUTING_STREAM_NAME
,
1110 .rates
= SNDRV_PCM_RATE_8000_192000
,
1111 .formats
= SND_SOC_ADV_MT_FMTS
,
1115 .name
= MT_SOC_CODEC_RXDAI2_NAME
,
1117 .stream_name
= MT_SOC_UL1DATA2_STREAM_NAME
,
1120 .rates
= SNDRV_PCM_RATE_8000_192000
,
1121 .formats
= SND_SOC_ADV_MT_FMTS
,
1125 .name
= MT_SOC_CODEC_MRGRX_DAI_NAME
,
1126 .ops
= &mt6323_aif1_dai_ops
,
1128 .stream_name
= MT_SOC_MRGRX_STREAM_NAME
,
1131 .rates
= SNDRV_PCM_RATE_8000_192000
,
1132 .formats
= SND_SOC_ADV_MT_FMTS
,
1135 .stream_name
= MT_SOC_MRGRX_STREAM_NAME
,
1138 .rates
= SNDRV_PCM_RATE_8000_192000
,
1139 .formats
= SND_SOC_ADV_MT_FMTS
,
1143 .name
= MT_SOC_CODEC_HP_IMPEDANCE_NAME
,
1144 .ops
= &mt6323_aif1_dai_ops
,
1146 .stream_name
= MT_SOC_HP_IMPEDANCE_STREAM_NAME
,
1149 .rates
= SNDRV_PCM_RATE_8000_192000
,
1150 .formats
= SND_SOC_ADV_MT_FMTS
,
1154 .name
= MT_SOC_CODEC_FM_I2S_DAI_NAME
,
1155 .ops
= &mt6323_aif1_dai_ops
,
1157 .stream_name
= MT_SOC_FM_I2S_PLAYBACK_STREAM_NAME
,
1160 .rates
= SNDRV_PCM_RATE_8000_192000
,
1161 .formats
= SND_SOC_ADV_MT_FMTS
,
1164 .stream_name
= MT_SOC_FM_I2S_PLAYBACK_STREAM_NAME
,
1167 .rates
= SNDRV_PCM_RATE_8000_192000
,
1168 .formats
= SND_SOC_ADV_MT_FMTS
,
1174 uint32
GetDLNewIFFrequency(unsigned int frequency
)
1176 uint32 Reg_value
= 0;
1177 //printk("AudioPlatformDevice ApplyDLNewIFFrequency ApplyDLNewIFFrequency = %d", frequency);
1207 printk("ApplyDLNewIFFrequency with frequency = %d", frequency
);
1212 static void TurnOnDacPower(void)
1214 printk("TurnOnDacPower\n");
1215 audckbufEnable(true);
1219 NvregEnable(true); //K2 moved to 0x0CEE
1220 if (GetAdcStatus() == false)
1222 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x003a, 0xffff); //power on clock
1226 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0000, 0xffff); //power on clock
1230 Ana_Set_Reg(AFUNC_AUD_CON2
, 0x0006, 0xffff); //sdm audio fifo clock power on
1231 Ana_Set_Reg(AFUNC_AUD_CON0
, 0xc3a1, 0xffff); //scrambler clock on enable
1232 Ana_Set_Reg(AFUNC_AUD_CON2
, 0x0003, 0xffff); //sdm power on
1233 Ana_Set_Reg(AFUNC_AUD_CON2
, 0x000b, 0xffff); //sdm fifo enable
1234 Ana_Set_Reg(AFE_DL_SDM_CON1
, 0x001e, 0xffff); //set attenuation gain
1235 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0001, 0xffff); //[0] afe enable
1237 Ana_Set_Reg(AFE_PMIC_NEWIF_CFG0
, GetDLNewIFFrequency(mBlockSampleRate
[AUDIO_ANALOG_DEVICE_OUT_DAC
]) << 12 | 0x330 , 0xffff);
1238 Ana_Set_Reg(AFE_DL_SRC2_CON0_H
, GetDLNewIFFrequency(mBlockSampleRate
[AUDIO_ANALOG_DEVICE_OUT_DAC
]) << 12 | 0x300 , 0xffff); //K2
1240 Ana_Set_Reg(AFE_DL_SRC2_CON0_L
, 0x0001 , 0xffff); //turn on dl
1241 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, 0x0000 , 0xffff); //set DL in normal path, not from sine gen table
1244 static void TurnOffDacPower(void)
1246 printk("TurnOffDacPower\n");
1248 Ana_Set_Reg(AFE_DL_SRC2_CON0_L
, 0x0000 , 0xffff); //bit0, Turn off down-link
1249 if (GetAdcStatus() == false)
1251 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0000, 0xffff); //turn off afe
1255 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0040, 0x0040); //down-link power down
1257 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0000, 0xffff); //Toggle RG_DIVCKS_CHG
1258 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0000, 0xffff); //Turn off DA_600K_NCP_VA18
1259 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0001, 0xffff); // Disable NCP
1262 Topck_Enable(false);
1263 audckbufEnable(false);
1266 static void HeadsetVoloumeRestore(void)
1268 int index
= 0, oldindex
= 0, offset
= 0, count
= 1;
1269 printk("%s\n", __func__
);
1271 oldindex
= mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
];
1272 if (index
> oldindex
)
1274 printk("index = %d oldindex = %d \n", index
, oldindex
);
1275 offset
= index
- oldindex
;
1278 Ana_Set_Reg(ZCD_CON2
, ((oldindex
+ count
) << 7) | (oldindex
+ count
) , 0xf9f);
1286 printk("index = %d oldindex = %d \n", index
, oldindex
);
1287 offset
= oldindex
- index
;
1290 Ana_Set_Reg(ZCD_CON2
, ((oldindex
- count
) << 7) | (oldindex
- count
) , 0xf9f);
1296 Ana_Set_Reg(ZCD_CON2
, 0x0489, 0xf9f);
1299 static void HeadsetVoloumeSet(void)
1301 int index
= 0, oldindex
= 0, offset
= 0, count
= 1;
1302 printk("%s\n", __func__
);
1303 index
= mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
];
1305 if (index
> oldindex
)
1307 printk("index = %d oldindex = %d \n", index
, oldindex
);
1308 offset
= index
- oldindex
;
1311 Ana_Set_Reg(ZCD_CON2
, ((oldindex
+ count
) << 7) | (oldindex
+ count
) , 0xf9f);
1319 printk("index = %d oldindex = %d \n", index
, oldindex
);
1320 offset
= oldindex
- index
;
1323 Ana_Set_Reg(ZCD_CON2
, ((oldindex
- count
) << 7) | (oldindex
- count
) , 0xf9f);
1329 Ana_Set_Reg(ZCD_CON2
, (index
<< 7) | (index
), 0xf9f);
1332 static void Audio_Amp_Change(int channels
, bool enable
)
1336 if (GetDLStatus() == false)
1340 // here pmic analog control
1341 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == false &&
1342 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == false)
1344 printk("%s \n", __func__
);
1346 //set analog part (HP playback)
1347 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
1348 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
1349 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
1350 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
1351 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
1352 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V) & LDO VA33REFGEN
1353 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
1354 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
1355 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
1356 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE080, 0xffff); //Disable headphone, voice and short-ckt protection. HP MUX is opened, voice MUX is set mute
1357 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
1358 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0700, 0xffff); //Enable HP & HS drivers bias circuit
1359 Ana_Set_Reg(AUDDEC_ANA_CON5
, 0x5490, 0xffff); //HP/HS ibias & DR bias current optimization
1361 Ana_Set_Reg(ZCD_CON2
, 0x0F9F, 0xffff); //Set HPR/HPL gain as minimum (~ -40dB)
1362 Ana_Set_Reg(ZCD_CON3
, 0x001F, 0xffff); //Set voice gain as minimum (~ -40dB)
1363 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //De_OSC of HP and enable output STBENH
1364 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //De_OSC of voice, enable output STBENH
1365 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE090, 0xffff); //Enable voice driver
1366 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x14A0, 0xffff); //Enable pre-charge buffer
1368 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
1369 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE09F, 0xffff); //Enable Audio DAC
1371 //Apply digital DC compensation value to DAC
1372 Ana_Set_Reg(ZCD_CON2
, 0x0489, 0xffff); //Set HPR/HPL gain to -1dB, step by step
1373 SetDcCompenSation();
1375 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF49F, 0xffff); //Switch HP MUX to audio DAC
1376 // here may cause pop
1377 //msleep(1); //K2 removed
1378 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF4FF, 0xffff); //Enable HPR/HPL
1380 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //Disable pre-charge buffer
1381 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //Disable De_OSC of voice
1382 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF46F, 0xffff); //Disable voice buffer & Open HS input MUX
1383 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0300, 0xffff); //Disable HS drivers bias circuit
1385 // apply volume setting
1386 HeadsetVoloumeSet();
1388 else if (channels
== AUDIO_ANALOG_CHANNELS_LEFT1
)
1391 else if (channels
== AUDIO_ANALOG_CHANNELS_RIGHT1
)
1397 if (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == false &&
1398 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == false)
1400 printk("Audio_Amp_Change off amp\n");
1401 HeadsetVoloumeRestore();// Set HPR/HPL gain as -1dB, step by step
1402 //Ana_Set_Reg(ZCD_CON2, 0x0F9F, 0xffff); //Set HPR/HPL gain as minimum (~ -40dB)
1403 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF40F, 0xffff); //Disable HPR/HPL
1405 else if (channels
== AUDIO_ANALOG_CHANNELS_LEFT1
)
1408 else if (channels
== AUDIO_ANALOG_CHANNELS_RIGHT1
)
1411 if (GetDLStatus() == false)
1413 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
1414 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
1415 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
1416 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
1417 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
1420 EnableDcCompensation(false);
1424 static int Audio_AmpL_Get(struct snd_kcontrol
*kcontrol
,
1425 struct snd_ctl_elem_value
*ucontrol
)
1427 printk("Audio_AmpL_Get = %d\n", mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
]);
1428 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
];
1432 static int Audio_AmpL_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1434 mutex_lock(&Ana_Ctrl_Mutex
);
1436 printk("%s() gain = %ld \n ", __func__
, ucontrol
->value
.integer
.value
[0]);
1437 if ((ucontrol
->value
.integer
.value
[0] == true) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == false))
1439 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, true);
1440 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = ucontrol
->value
.integer
.value
[0];
1442 else if ((ucontrol
->value
.integer
.value
[0] == false) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] == true))
1444 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETL
] = ucontrol
->value
.integer
.value
[0];
1445 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_LEFT1
, false);
1447 mutex_unlock(&Ana_Ctrl_Mutex
);
1451 static int Audio_AmpR_Get(struct snd_kcontrol
*kcontrol
,
1452 struct snd_ctl_elem_value
*ucontrol
)
1454 printk("Audio_AmpR_Get = %d\n", mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
]);
1455 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
];
1459 static int Audio_AmpR_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1461 mutex_lock(&Ana_Ctrl_Mutex
);
1463 printk("%s()\n", __func__
);
1464 if ((ucontrol
->value
.integer
.value
[0] == true) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == false))
1466 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, true);
1467 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = ucontrol
->value
.integer
.value
[0];
1469 else if ((ucontrol
->value
.integer
.value
[0] == false) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] == true))
1471 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_HEADSETR
] = ucontrol
->value
.integer
.value
[0];
1472 Audio_Amp_Change(AUDIO_ANALOG_CHANNELS_RIGHT1
, false);
1474 mutex_unlock(&Ana_Ctrl_Mutex
);
1479 static void SetVoiceAmpVolume(void)
1482 printk("%s\n", __func__
);
1483 index
= mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HSOUTL
];
1484 Ana_Set_Reg(ZCD_CON3
, index
, 0x001f);
1488 static void Voice_Amp_Change(bool enable
)
1492 printk("%s \n", __func__
);
1493 if (GetDLStatus() == false)
1496 printk("Voice_Amp_Change on amp\n");
1498 //set analog part (voice HS playback)
1499 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
1500 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
1501 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
1502 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
1503 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
1504 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A40, 0xfeeb); //Enable cap-less HC LDO (1.5V)
1505 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable cap-less LC LDO (1.5V)
1506 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
1507 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
1508 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE080, 0xffff); //Disable headphone, voice and short-ckt protection. HP MUX is opened, voice MUX is set mute
1509 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
1510 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0400, 0xffff); //Enable HS drivers bias circuit
1511 Ana_Set_Reg(AUDDEC_ANA_CON5
, 0x5490, 0xffff); //HP/HS ibias & DR bias current optimization
1513 Ana_Set_Reg(ZCD_CON3
, 0x001F, 0xffff); //Set voice gain as minimum (~ -40dB)
1514 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1000, 0xffff); //De_OSC of voice, enable output STBENH
1515 //Ana_Set_Reg(AUDDEC_ANA_CON6, 0x2AC2, 0xfeeb); //Enable AUD_CLK
1516 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2BC6, 0xffff); //Enable AUD_CLK
1517 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE089, 0xffff); //Enable Audio DAC
1519 //Apply digital DC compensation value to DAC
1520 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE109, 0xffff); //Switch HS MUX to audio DAC
1521 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE119, 0xffff); //Enable voice driver
1523 Ana_Set_Reg(ZCD_CON3
, 0x0000, 0xffff); //Set HS gain to +8dB(for SMT), step by step
1528 printk("turn off ampL\n");
1529 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE109 , 0xffff); //Disable voice driver
1531 if (GetDLStatus() == false)
1533 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
1534 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
1535 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
1536 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
1537 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
1544 static int Voice_Amp_Get(struct snd_kcontrol
*kcontrol
,
1545 struct snd_ctl_elem_value
*ucontrol
)
1547 printk("Voice_Amp_Get = %d\n", mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
]);
1548 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
];
1552 static int Voice_Amp_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1554 mutex_lock(&Ana_Ctrl_Mutex
);
1555 printk("%s()\n", __func__
);
1556 if ((ucontrol
->value
.integer
.value
[0] == true) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] == false))
1558 Voice_Amp_Change(true);
1559 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] = ucontrol
->value
.integer
.value
[0];
1561 else if ((ucontrol
->value
.integer
.value
[0] == false) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] == true))
1563 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EARPIECEL
] = ucontrol
->value
.integer
.value
[0];
1564 Voice_Amp_Change(false);
1566 mutex_unlock(&Ana_Ctrl_Mutex
);
1570 static void Speaker_Amp_Change(bool enable
)
1574 if (GetDLStatus() == false)
1578 printk("%s \n", __func__
);
1579 // ClassAB spk pmic analog control
1580 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
1581 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
1582 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
1583 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
1584 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
1585 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V)
1586 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
1587 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
1588 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
1590 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
1591 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
1592 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0009, 0x0009); //Enable Audio DAC Lch
1594 //SetDcCompenSation();
1596 Ana_Set_Reg(ZCD_CON0
, 0x0400, 0xffff); //Disable IVBUF_ZCD
1597 Ana_Set_Reg(ZCD_CON4
, 0x0705, 0xffff); //Set 0dB IV buffer gain
1598 Ana_Set_Reg(SPK_ANA_CON3
, 0x0100, 0xffff); //Set IV buffer MUX select
1599 Ana_Set_Reg(SPK_ANA_CON3
, 0x0110, 0xffff); //Enable IV buffer
1600 Ana_Set_Reg(TOP_CKPDN_CON2_CLR
, 0x0003, 0xffff); //Enable ClassAB/D clock
1602 #ifdef CONFIG_MTK_SPEAKER
1603 if (Speaker_mode
== AUDIO_SPEAKER_MODE_D
)
1605 Speaker_ClassD_Open();
1607 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_AB
)
1609 Speaker_ClassAB_Open();
1611 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_RECEIVER
)
1613 Speaker_ReveiverMode_Open();
1616 Apply_Speaker_Gain();
1620 printk("turn off Speaker_Amp_Change \n");
1621 #ifdef CONFIG_MTK_SPEAKER
1622 if (Speaker_mode
== AUDIO_SPEAKER_MODE_D
)
1624 Speaker_ClassD_close();
1626 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_AB
)
1628 Speaker_ClassAB_close();
1630 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_RECEIVER
)
1632 Speaker_ReveiverMode_close();
1635 Ana_Set_Reg(TOP_CKPDN_CON2_SET
, 0x0003, 0xffff); //Disable ClassAB/D clock
1636 Ana_Set_Reg(SPK_ANA_CON3
, 0x0, 0xffff); //Disable IV buffer, Set IV buffer MUX select open/open
1637 Ana_Set_Reg(ZCD_CON4
, 0x0707, 0xffff); //Set min -2dB IV buffer gain
1639 if (GetDLStatus() == false)
1641 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
1642 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
1643 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
1644 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
1645 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
1652 static int Speaker_Amp_Get(struct snd_kcontrol
*kcontrol
,
1653 struct snd_ctl_elem_value
*ucontrol
)
1655 printk("%s()\n", __func__
);
1656 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] ;
1660 static int Speaker_Amp_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1662 printk("%s() value = %ld \n ", __func__
, ucontrol
->value
.integer
.value
[0]);
1663 if ((ucontrol
->value
.integer
.value
[0] == true) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] == false))
1665 Speaker_Amp_Change(true);
1666 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] = ucontrol
->value
.integer
.value
[0];
1668 else if ((ucontrol
->value
.integer
.value
[0] == false) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] == true))
1670 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKERL
] = ucontrol
->value
.integer
.value
[0];
1671 Speaker_Amp_Change(false);
1676 static unsigned int pin_extspkamp
, pin_vowclk
, pin_audmiso
;
1677 static unsigned int pin_mode_extspkamp
, pin_mode_vowclk
, pin_mode_audmiso
;
1682 #define GAP (2) //unit: us
1683 #define AW8736_MODE3 /*0.8w*/ \
1684 mt_set_gpio_out(pin_extspkamp,GPIO_OUT_ONE); \
1686 mt_set_gpio_out(pin_extspkamp,GPIO_OUT_ZERO); \
1688 mt_set_gpio_out(pin_extspkamp,GPIO_OUT_ONE); \
1690 mt_set_gpio_out(pin_extspkamp,GPIO_OUT_ZERO); \
1692 mt_set_gpio_out(pin_extspkamp,GPIO_OUT_ONE);
1694 static void Ext_Speaker_Amp_Change(bool enable
)
1696 #define SPK_WARM_UP_TIME (25) //unit is ms
1699 ret
= GetGPIO_Info(5, &pin_extspkamp
, &pin_mode_extspkamp
);
1702 printk("Ext_Speaker_Amp_Change GetGPIO_Info FAIL!!! \n");
1708 printk("Ext_Speaker_Amp_Change ON+ \n");
1709 #ifndef CONFIG_MTK_SPEAKER
1710 printk("Ext_Speaker_Amp_Change ON set GPIO \n");
1711 mt_set_gpio_mode(pin_extspkamp
, GPIO_MODE_00
); //GPIO117: DPI_D3, mode 0
1712 mt_set_gpio_pull_enable(pin_extspkamp
, GPIO_PULL_ENABLE
);
1713 mt_set_gpio_dir(pin_extspkamp
, GPIO_DIR_OUT
); // output
1714 mt_set_gpio_out(pin_extspkamp
, GPIO_OUT_ZERO
); // low disable
1716 mt_set_gpio_dir(pin_extspkamp
, GPIO_DIR_OUT
); // output
1718 #ifdef AW8736_MODE_CTRL
1721 mt_set_gpio_out(pin_extspkamp
, GPIO_OUT_ONE
); // high enable
1723 msleep(SPK_WARM_UP_TIME
);
1725 printk("Ext_Speaker_Amp_Change ON- \n");
1729 printk("Ext_Speaker_Amp_Change OFF+ \n");
1730 #ifndef CONFIG_MTK_SPEAKER
1731 //mt_set_gpio_mode(pin_extspkamp, GPIO_MODE_00); //GPIO117: DPI_D3, mode 0
1732 mt_set_gpio_dir(pin_extspkamp
, GPIO_DIR_OUT
); // output
1733 mt_set_gpio_out(pin_extspkamp
, GPIO_OUT_ZERO
); // low disbale
1736 printk("Ext_Speaker_Amp_Change OFF- \n");
1741 #ifndef CONFIG_MTK_SPEAKER
1742 #ifdef AW8736_MODE_CTRL
1743 /* 0.75us<TL<10us; 0.75us<TH<10us */
1744 #define GAP (2) //unit: us
1745 #define AW8736_MODE1 /*1.2w*/ \
1746 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE);
1748 #define AW8736_MODE2 /*1.0w*/ \
1749 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1751 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1753 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE);
1755 #define AW8736_MODE3 /*0.8w*/ \
1756 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1758 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1760 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1762 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1764 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE);
1766 #define AW8736_MODE4 /*it depends on THD, range: 1.5 ~ 2.0w*/ \
1767 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1769 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1771 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1773 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1775 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE); \
1777 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ZERO); \
1779 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN,GPIO_OUT_ONE);
1783 static void Ext_Speaker_Amp_Change(bool enable
)
1785 #define SPK_WARM_UP_TIME (25) //unit is ms
1789 printk("Ext_Speaker_Amp_Change ON+ \n");
1790 #ifndef CONFIG_MTK_SPEAKER
1791 printk("Ext_Speaker_Amp_Change ON set GPIO \n");
1792 mt_set_gpio_mode(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_MODE_00
); //GPIO117: DPI_D3, mode 0
1793 mt_set_gpio_pull_enable(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_PULL_ENABLE
);
1794 mt_set_gpio_dir(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_DIR_OUT
); // output
1795 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_OUT_ZERO
); // low disable
1797 mt_set_gpio_dir(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_DIR_OUT
); // output
1799 #ifdef AW8736_MODE_CTRL
1802 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_OUT_ONE
); // high enable
1804 msleep(SPK_WARM_UP_TIME
);
1806 printk("Ext_Speaker_Amp_Change ON- \n");
1810 printk("Ext_Speaker_Amp_Change OFF+ \n");
1811 #ifndef CONFIG_MTK_SPEAKER
1812 //mt_set_gpio_mode(GPIO_EXT_SPKAMP_EN_PIN, GPIO_MODE_00); //GPIO117: DPI_D3, mode 0
1813 mt_set_gpio_dir(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_DIR_OUT
); // output
1814 mt_set_gpio_out(GPIO_EXT_SPKAMP_EN_PIN
, GPIO_OUT_ZERO
); // low disbale
1817 printk("Ext_Speaker_Amp_Change OFF- \n");
1822 static int Ext_Speaker_Amp_Get(struct snd_kcontrol
*kcontrol
,
1823 struct snd_ctl_elem_value
*ucontrol
)
1825 printk("%s()\n", __func__
);
1826 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EXTSPKAMP
] ;
1830 static int Ext_Speaker_Amp_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1833 printk("%s() gain = %ld \n ", __func__
, ucontrol
->value
.integer
.value
[0]);
1834 if (ucontrol
->value
.integer
.value
[0])
1836 Ext_Speaker_Amp_Change(true);
1837 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EXTSPKAMP
] = ucontrol
->value
.integer
.value
[0];
1841 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_EXTSPKAMP
] = ucontrol
->value
.integer
.value
[0];
1842 Ext_Speaker_Amp_Change(false);
1847 static void Headset_Speaker_Amp_Change(bool enable
)
1851 if (GetDLStatus() == false)
1855 printk("turn on Speaker_Amp_Change \n");
1856 // here pmic analog control
1857 //set analog part (HP playback)
1858 Ana_Set_Reg(AUDNCP_CLKDIV_CON1
, 0x0001, 0xffff); //Turn on DA_600K_NCP_VA18
1859 Ana_Set_Reg(AUDNCP_CLKDIV_CON2
, 0x002B, 0xffff); //Set NCP clock as 604kHz // 26MHz/43 = 604KHz
1860 Ana_Set_Reg(AUDNCP_CLKDIV_CON0
, 0x0001, 0xffff); //Toggle RG_DIVCKS_CHG
1861 Ana_Set_Reg(AUDNCP_CLKDIV_CON4
, 0x0000, 0xffff); //Set NCP soft start mode as default mode
1862 Ana_Set_Reg(AUDNCP_CLKDIV_CON3
, 0x0000, 0xffff); //Enable NCP
1863 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0A41, 0xfeeb); //Enable cap-less HC LDO (1.5V) & LDO VA33REFGEN
1864 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC1, 0xfeeb); //Enable cap-less LC LDO (1.5V)
1865 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x8000, 0x8000); //Enable NV regulator (-1.5V)
1866 Ana_Set_Reg(ZCD_CON0
, 0x0000, 0xffff); //Disable AUD_ZCD
1867 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE080, 0xffff); //Disable headphone, voice and short-ckt protection. HP MUX is opened, voice MUX is set mute
1868 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Enable IBIST
1869 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0700, 0xffff); //Enable HP & HS drivers bias circuit
1870 Ana_Set_Reg(AUDDEC_ANA_CON5
, 0x5490, 0xffff); //HP/HS ibias & DR bias current optimization
1872 Ana_Set_Reg(ZCD_CON2
, 0x0F9F, 0xffff); //Set HPR/HPL gain as minimum (~ -40dB)
1873 Ana_Set_Reg(ZCD_CON3
, 0x001F, 0xffff); //Set voice gain as minimum (~ -40dB)
1874 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //De_OSC of HP and enable output STBENH
1875 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //De_OSC of voice, enable output STBENH
1876 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE090, 0xffff); //Enable voice driver
1877 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x14A0, 0xffff); //Enable pre-charge buffer
1879 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC2, 0xfeeb); //Enable AUD_CLK
1880 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xE09F, 0xffff); //Enable Audio DAC
1882 //Apply digital DC compensation value to DAC
1883 Ana_Set_Reg(ZCD_CON2
, 0x0489, 0xffff); //Set HPR/HPL gain to -1dB, step by step
1884 SetDcCompenSation_SPKHP();
1886 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF29F, 0xffff); //R hp input mux select "Audio playback", L hp input mux select "LoudSPK playback"
1887 // here may cause pop?
1888 //msleep(1); //K2 removed
1889 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF2FF, 0xffff); //Enable HPR/HPL
1891 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x1480, 0xffff); //Disable pre-charge buffer
1892 Ana_Set_Reg(AUDDEC_ANA_CON1
, 0x0480, 0xffff); //Disable De_OSC of voice
1893 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF26F, 0xffff); //Disable voice buffer & Open HS input MUX
1894 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0300, 0xffff); //Disable HS drivers bias circuit
1896 // ClassAB spk pmic analog control
1897 Ana_Set_Reg(ZCD_CON0
, 0x0400, 0xffff); //Disable IVBUF_ZCD
1898 Ana_Set_Reg(ZCD_CON4
, 0x0705, 0xffff); //Set 0dB IV buffer gain
1899 Ana_Set_Reg(SPK_ANA_CON3
, 0x0100, 0xffff); //Set IV buffer MUX select
1900 Ana_Set_Reg(SPK_ANA_CON3
, 0x0110, 0xffff); //Enable IV buffer
1901 Ana_Set_Reg(TOP_CKPDN_CON2_CLR
, 0x0003, 0xffff); //Enable ClassAB/D clock
1903 #ifdef CONFIG_MTK_SPEAKER
1904 if (Speaker_mode
== AUDIO_SPEAKER_MODE_D
)
1906 Speaker_ClassD_Open();
1908 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_AB
)
1910 Speaker_ClassAB_Open();
1912 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_RECEIVER
)
1914 Speaker_ReveiverMode_Open();
1917 // apply volume setting
1918 HeadsetVoloumeSet();
1919 Apply_Speaker_Gain();
1923 #ifdef CONFIG_MTK_SPEAKER
1924 if (Speaker_mode
== AUDIO_SPEAKER_MODE_D
)
1926 Speaker_ClassD_close();
1928 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_AB
)
1930 Speaker_ClassAB_close();
1932 else if (Speaker_mode
== AUDIO_SPEAKER_MODE_RECEIVER
)
1934 Speaker_ReveiverMode_close();
1937 Ana_Set_Reg(TOP_CKPDN_CON2_SET
, 0x0003, 0xffff); //Disable ClassAB/D clock
1938 Ana_Set_Reg(SPK_ANA_CON3
, 0x0, 0xffff); //Disable IV buffer, Set IV buffer MUX select open/open
1939 Ana_Set_Reg(ZCD_CON4
, 0x0707, 0xffff); //Set min -2dB IV buffer gain
1941 HeadsetVoloumeRestore();// Set HPR/HPL gain as 0dB, step by step
1942 //Ana_Set_Reg(ZCD_CON2, 0x0F9F, 0xffff); //Set HPR/HPL gain as minimum (~ -40dB)
1943 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xF20F, 0xffff); //Disable HPR/HPL
1944 if (GetDLStatus() == false)
1946 Ana_Set_Reg(AUDDEC_ANA_CON4
, 0x0000, 0xffff); //Disable drivers bias circuit
1947 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0x0000, 0xffff); //Disable Audio DAC
1948 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x2AC0, 0xfeeb); //Disable AUD_CLK, bit2/4/8 is for ADC, do not set
1949 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x8000); //Disable NV regulator (-1.5V)
1950 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0001, 0xfeeb); //Disable cap-less LDOs (1.5V) & Disable IBIST
1954 EnableDcCompensation(false);
1959 static int Headset_Speaker_Amp_Get(struct snd_kcontrol
*kcontrol
,
1960 struct snd_ctl_elem_value
*ucontrol
)
1962 printk("%s()\n", __func__
);
1963 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKER_HEADSET_R
] ;
1967 static int Headset_Speaker_Amp_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1969 //struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1971 printk("%s() gain = %lu \n ", __func__
, ucontrol
->value
.integer
.value
[0]);
1972 if ((ucontrol
->value
.integer
.value
[0] == true) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKER_HEADSET_R
] == false))
1974 Headset_Speaker_Amp_Change(true);
1975 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKER_HEADSET_R
] = ucontrol
->value
.integer
.value
[0];
1977 else if ((ucontrol
->value
.integer
.value
[0] == false) && (mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKER_HEADSET_R
] == true))
1979 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_OUT_SPEAKER_HEADSET_R
] = ucontrol
->value
.integer
.value
[0];
1980 Headset_Speaker_Amp_Change(false);
1985 #ifdef CONFIG_MTK_SPEAKER
1986 static const char *speaker_amp_function
[] = {"CALSSD", "CLASSAB", "RECEIVER"};
1987 static const char *speaker_PGA_function
[] = {"MUTE", "0Db", "4Db", "5Db", "6Db", "7Db", "8Db", "9Db", "10Db",
1988 "11Db", "12Db", "13Db", "14Db", "15Db", "16Db", "17Db"
1990 static const char *speaker_OC_function
[] = {"Off", "On"};
1991 static const char *speaker_CS_function
[] = {"Off", "On"};
1992 static const char *speaker_CSPeakDetecReset_function
[] = {"Off", "On"};
1994 static int Audio_Speaker_Class_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1996 mutex_lock(&Ana_Ctrl_Mutex
);
1997 Speaker_mode
= ucontrol
->value
.integer
.value
[0];
1998 mutex_unlock(&Ana_Ctrl_Mutex
);
2002 static int Audio_Speaker_Class_Get(struct snd_kcontrol
*kcontrol
,
2003 struct snd_ctl_elem_value
*ucontrol
)
2005 ucontrol
->value
.integer
.value
[0] = Speaker_mode
;
2009 static int Audio_Speaker_Pga_Gain_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2011 Speaker_pga_gain
= ucontrol
->value
.integer
.value
[0];
2013 printk("%s Speaker_pga_gain= %d\n", __func__
, Speaker_pga_gain
);
2014 Ana_Set_Reg(SPK_ANA_CON0
, Speaker_pga_gain
<< 11, 0x7800);
2018 static int Audio_Speaker_OcFlag_Get(struct snd_kcontrol
*kcontrol
,
2019 struct snd_ctl_elem_value
*ucontrol
)
2021 mSpeaker_Ocflag
= GetSpeakerOcFlag();
2022 ucontrol
->value
.integer
.value
[0] = mSpeaker_Ocflag
;
2026 static int Audio_Speaker_OcFlag_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2028 printk("%s is not support setting \n", __func__
);
2032 static int Audio_Speaker_Pga_Gain_Get(struct snd_kcontrol
*kcontrol
,
2033 struct snd_ctl_elem_value
*ucontrol
)
2035 ucontrol
->value
.integer
.value
[0] = Speaker_pga_gain
;
2039 static int Audio_Speaker_Current_Sensing_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2042 if (ucontrol
->value
.integer
.value
[0])
2044 Ana_Set_Reg(SPK_CON12
, 0x9300, 0xff00);
2048 Ana_Set_Reg(SPK_CON12
, 0x1300, 0xff00);
2053 static int Audio_Speaker_Current_Sensing_Get(struct snd_kcontrol
*kcontrol
,
2054 struct snd_ctl_elem_value
*ucontrol
)
2056 ucontrol
->value
.integer
.value
[0] = (Ana_Get_Reg(SPK_CON12
) >> 15) & 0x01;
2060 static int Audio_Speaker_Current_Sensing_Peak_Detector_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2063 if (ucontrol
->value
.integer
.value
[0])
2065 Ana_Set_Reg(SPK_CON12
, 1 << 14, 1 << 14);
2069 Ana_Set_Reg(SPK_CON12
, 0, 1 << 14);
2074 static int Audio_Speaker_Current_Sensing_Peak_Detector_Get(struct snd_kcontrol
*kcontrol
,
2075 struct snd_ctl_elem_value
*ucontrol
)
2077 ucontrol
->value
.integer
.value
[0] = (Ana_Get_Reg(SPK_CON12
) >> 14) & 0x01;
2082 static const struct soc_enum Audio_Speaker_Enum
[] =
2084 // speaker class setting
2085 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(speaker_amp_function
), speaker_amp_function
),
2086 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(speaker_PGA_function
), speaker_PGA_function
),
2087 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(speaker_OC_function
), speaker_OC_function
),
2088 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(speaker_CS_function
), speaker_CS_function
),
2089 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(speaker_CSPeakDetecReset_function
), speaker_CSPeakDetecReset_function
),
2092 static const struct snd_kcontrol_new mt6331_snd_Speaker_controls
[] =
2094 SOC_ENUM_EXT("Audio_Speaker_class_Switch", Audio_Speaker_Enum
[0], Audio_Speaker_Class_Get
, Audio_Speaker_Class_Set
),
2095 SOC_ENUM_EXT("Audio_Speaker_PGA_gain", Audio_Speaker_Enum
[1], Audio_Speaker_Pga_Gain_Get
, Audio_Speaker_Pga_Gain_Set
),
2096 SOC_ENUM_EXT("Audio_Speaker_OC_Falg", Audio_Speaker_Enum
[2], Audio_Speaker_OcFlag_Get
, Audio_Speaker_OcFlag_Set
),
2097 SOC_ENUM_EXT("Audio_Speaker_CurrentSensing", Audio_Speaker_Enum
[3], Audio_Speaker_Current_Sensing_Get
, Audio_Speaker_Current_Sensing_Set
),
2098 SOC_ENUM_EXT("Audio_Speaker_CurrentPeakDetector", Audio_Speaker_Enum
[4], Audio_Speaker_Current_Sensing_Peak_Detector_Get
, Audio_Speaker_Current_Sensing_Peak_Detector_Set
),
2101 int Audio_AuxAdcData_Get_ext(void)
2103 int dRetValue
= PMIC_IMM_GetOneChannelValue(AUX_ICLASSAB_AP
, 1, 0);
2104 printk("%s dRetValue 0x%x \n", __func__
, dRetValue
);
2111 static int Audio_AuxAdcData_Get(struct snd_kcontrol
*kcontrol
,
2112 struct snd_ctl_elem_value
*ucontrol
)
2115 #ifdef CONFIG_MTK_SPEAKER
2116 ucontrol
->value
.integer
.value
[0] = Audio_AuxAdcData_Get_ext();//PMIC_IMM_GetSPK_THR_IOneChannelValue(0x001B, 1, 0);
2118 ucontrol
->value
.integer
.value
[0] = 0;
2120 printk("%s dMax = 0x%lx \n", __func__
, ucontrol
->value
.integer
.value
[0]);
2125 static int Audio_AuxAdcData_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2127 dAuxAdcChannel
= ucontrol
->value
.integer
.value
[0];
2128 printk("%s dAuxAdcChannel = 0x%x \n", __func__
, dAuxAdcChannel
);
2133 static const struct snd_kcontrol_new Audio_snd_auxadc_controls
[] =
2135 SOC_SINGLE_EXT("Audio AUXADC Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_AuxAdcData_Get
, Audio_AuxAdcData_Set
),
2139 static const char *amp_function
[] = {"Off", "On"};
2140 static const char *aud_clk_buf_function
[] = {"Off", "On"};
2142 //static const char *DAC_SampleRate_function[] = {"8000", "11025", "16000", "24000", "32000", "44100", "48000"};
2143 static const char *DAC_DL_PGA_Headset_GAIN
[] = {"8Db", "7Db", "6Db", "5Db", "4Db", "3Db", "2Db", "1Db", "0Db", "-1Db", "-2Db", "-3Db",
2144 "-4Db", "-5Db", "-6Db", "-7Db", "-8Db", "-9Db", "-10Db" , "-40Db"
2146 static const char *DAC_DL_PGA_Handset_GAIN
[] = {"8Db", "7Db", "6Db", "5Db", "4Db", "3Db", "2Db", "1Db", "0Db", "-1Db", "-2Db", "-3Db",
2147 "-4Db", "-5Db", "-6Db", "-7Db", "-8Db", "-9Db", "-10Db" , "-40Db"
2150 static const char *DAC_DL_PGA_Speaker_GAIN
[] = {"8Db", "7Db", "6Db", "5Db", "4Db", "3Db", "2Db", "1Db", "0Db", "-1Db", "-2Db", "-3Db",
2151 "-4Db", "-5Db", "-6Db", "-7Db", "-8Db", "-9Db", "-10Db" , "-40Db"
2154 //static const char *Voice_Mux_function[] = {"Voice", "Speaker"};
2156 static int Lineout_PGAL_Get(struct snd_kcontrol
*kcontrol
,
2157 struct snd_ctl_elem_value
*ucontrol
)
2159 printk("Speaker_PGA_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKL
]);
2160 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKL
];
2164 static int Lineout_PGAL_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2167 printk("%s(), index = %d\n", __func__
, ucontrol
->value
.enumerated
.item
[0]);
2169 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
))
2171 printk("return -EINVAL\n");
2174 index
= ucontrol
->value
.integer
.value
[0];
2175 if (ucontrol
->value
.enumerated
.item
[0] == (ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
) - 1))
2179 Ana_Set_Reg(ZCD_CON1
, index
, 0x001f);
2180 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKL
] = ucontrol
->value
.integer
.value
[0];
2184 static int Lineout_PGAR_Get(struct snd_kcontrol
*kcontrol
,
2185 struct snd_ctl_elem_value
*ucontrol
)
2187 printk("%s = %d\n", __func__
, mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKR
]);
2188 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKR
];
2192 static int Lineout_PGAR_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2194 // struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2196 printk("%s(), index = %d\n", __func__
, ucontrol
->value
.enumerated
.item
[0]);
2198 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
))
2200 printk("return -EINVAL\n");
2203 index
= ucontrol
->value
.integer
.value
[0];
2204 if (ucontrol
->value
.enumerated
.item
[0] == (ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
) - 1))
2208 Ana_Set_Reg(ZCD_CON1
, index
<< 7 , 0x0f10);
2209 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_SPKR
] = ucontrol
->value
.integer
.value
[0];
2213 static int Handset_PGA_Get(struct snd_kcontrol
*kcontrol
,
2214 struct snd_ctl_elem_value
*ucontrol
)
2216 printk("Handset_PGA_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HSOUTL
]);
2217 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HSOUTL
];
2221 static int Handset_PGA_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2223 // struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2226 printk("%s(), index = %d\n", __func__
, ucontrol
->value
.enumerated
.item
[0]);
2228 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(DAC_DL_PGA_Handset_GAIN
))
2230 printk("return -EINVAL\n");
2233 index
= ucontrol
->value
.integer
.value
[0];
2234 if (ucontrol
->value
.enumerated
.item
[0] == (ARRAY_SIZE(DAC_DL_PGA_Handset_GAIN
) - 1))
2238 Ana_Set_Reg(ZCD_CON3
, index
, 0x001f);
2239 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HSOUTL
] = ucontrol
->value
.integer
.value
[0];
2243 static int Headset_PGAL_Get(struct snd_kcontrol
*kcontrol
,
2244 struct snd_ctl_elem_value
*ucontrol
)
2246 printk("Headset_PGAL_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTL
]);
2247 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTL
];
2251 static int Headset_PGAL_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2253 // struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2256 //printk("%s(), index = %d arraysize = %d \n", __func__, ucontrol->value.enumerated.item[0], ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN)); //mark for 64bit build fail
2258 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
))
2260 printk("return -EINVAL\n");
2263 index
= ucontrol
->value
.integer
.value
[0];
2264 if (ucontrol
->value
.enumerated
.item
[0] == (ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
) - 1))
2268 Ana_Set_Reg(ZCD_CON2
, index
, 0x001f);
2269 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTL
] = ucontrol
->value
.integer
.value
[0];
2273 static int Headset_PGAR_Get(struct snd_kcontrol
*kcontrol
,
2274 struct snd_ctl_elem_value
*ucontrol
)
2276 printk("Headset_PGAR_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
]);
2277 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
];
2282 static int Headset_PGAR_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2284 // struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2287 printk("%s(), index = %d\n", __func__
, ucontrol
->value
.enumerated
.item
[0]);
2289 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
))
2291 printk("return -EINVAL\n");
2294 index
= ucontrol
->value
.integer
.value
[0];
2295 if (ucontrol
->value
.enumerated
.item
[0] == (ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
) - 1))
2299 Ana_Set_Reg(ZCD_CON2
, index
<< 7, 0x0f80);
2300 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
] = ucontrol
->value
.integer
.value
[0];
2304 static uint32 mHp_Impedance
= 32;
2306 static int Audio_Hp_Impedance_Get(struct snd_kcontrol
*kcontrol
,
2307 struct snd_ctl_elem_value
*ucontrol
)
2309 printk("Audio_Hp_Impedance_Get = %d\n", mHp_Impedance
);
2310 ucontrol
->value
.integer
.value
[0] = mHp_Impedance
;
2315 static int Audio_Hp_Impedance_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2317 mHp_Impedance
= ucontrol
->value
.integer
.value
[0];
2318 printk("%s Audio_Hp_Impedance_Set = 0x%x \n", __func__
, mHp_Impedance
);
2322 static int Aud_Clk_Buf_Get(struct snd_kcontrol
*kcontrol
,
2323 struct snd_ctl_elem_value
*ucontrol
)
2325 printk("\%s n", __func__
);
2326 ucontrol
->value
.integer
.value
[0] = audck_buf_Count
;
2330 static int Aud_Clk_Buf_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2332 printk("%s(), value = %d\n", __func__
, ucontrol
->value
.enumerated
.item
[0]);
2333 if (ucontrol
->value
.integer
.value
[0])
2335 audckbufEnable(true);
2339 audckbufEnable(false);
2345 static const struct soc_enum Audio_DL_Enum
[] =
2347 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2348 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2349 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2350 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2351 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2352 // here comes pga gain setting
2353 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
), DAC_DL_PGA_Headset_GAIN
),
2354 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(DAC_DL_PGA_Headset_GAIN
), DAC_DL_PGA_Headset_GAIN
),
2355 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(DAC_DL_PGA_Handset_GAIN
), DAC_DL_PGA_Handset_GAIN
),
2356 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
), DAC_DL_PGA_Speaker_GAIN
),
2357 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(DAC_DL_PGA_Speaker_GAIN
), DAC_DL_PGA_Speaker_GAIN
),
2358 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(aud_clk_buf_function
), aud_clk_buf_function
),
2359 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(amp_function
), amp_function
),
2362 static const struct snd_kcontrol_new mt6331_snd_controls
[] =
2364 SOC_ENUM_EXT("Audio_Amp_R_Switch", Audio_DL_Enum
[0], Audio_AmpR_Get
, Audio_AmpR_Set
),
2365 SOC_ENUM_EXT("Audio_Amp_L_Switch", Audio_DL_Enum
[1], Audio_AmpL_Get
, Audio_AmpL_Set
),
2366 SOC_ENUM_EXT("Voice_Amp_Switch", Audio_DL_Enum
[2], Voice_Amp_Get
, Voice_Amp_Set
),
2367 SOC_ENUM_EXT("Speaker_Amp_Switch", Audio_DL_Enum
[3], Speaker_Amp_Get
, Speaker_Amp_Set
),
2368 SOC_ENUM_EXT("Headset_Speaker_Amp_Switch", Audio_DL_Enum
[4], Headset_Speaker_Amp_Get
, Headset_Speaker_Amp_Set
),
2369 SOC_ENUM_EXT("Headset_PGAL_GAIN", Audio_DL_Enum
[5], Headset_PGAL_Get
, Headset_PGAL_Set
),
2370 SOC_ENUM_EXT("Headset_PGAR_GAIN", Audio_DL_Enum
[6], Headset_PGAR_Get
, Headset_PGAR_Set
),
2371 SOC_ENUM_EXT("Handset_PGA_GAIN", Audio_DL_Enum
[7], Handset_PGA_Get
, Handset_PGA_Set
),
2372 SOC_ENUM_EXT("Lineout_PGAR_GAIN", Audio_DL_Enum
[8], Lineout_PGAR_Get
, Lineout_PGAR_Set
),
2373 SOC_ENUM_EXT("Lineout_PGAL_GAIN", Audio_DL_Enum
[9], Lineout_PGAL_Get
, Lineout_PGAL_Set
),
2374 SOC_ENUM_EXT("AUD_CLK_BUF_Switch", Audio_DL_Enum
[10], Aud_Clk_Buf_Get
, Aud_Clk_Buf_Set
),
2375 SOC_ENUM_EXT("Ext_Speaker_Amp_Switch", Audio_DL_Enum
[11], Ext_Speaker_Amp_Get
, Ext_Speaker_Amp_Set
),
2376 SOC_SINGLE_EXT("Audio HP Impedance", SND_SOC_NOPM
, 0, 512, 0, Audio_Hp_Impedance_Get
, Audio_Hp_Impedance_Set
),
2379 static const struct snd_kcontrol_new mt6331_Voice_Switch
[] =
2381 //SOC_DAPM_ENUM_EXT("Voice Mux", Audio_DL_Enum[10], Voice_Mux_Get, Voice_Mux_Set),
2384 void SetMicPGAGain(void)
2387 index
= mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP1
];
2388 Ana_Set_Reg(AUDENC_ANA_CON15
, index
, 0x0007);
2389 index
= mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP2
];
2390 Ana_Set_Reg(AUDENC_ANA_CON15
, index
<< 4, 0x0070);
2393 static bool GetAdcStatus(void)
2396 for (i
= AUDIO_ANALOG_DEVICE_IN_ADC1
; i
< AUDIO_ANALOG_DEVICE_MAX
; i
++)
2398 if (mCodec_data
->mAudio_Ana_DevicePower
[i
] == true)
2406 static bool GetDacStatus(void)
2409 for (i
= AUDIO_ANALOG_DEVICE_OUT_EARPIECER
; i
< AUDIO_ANALOG_DEVICE_2IN1_SPK
; i
++)
2411 if (mCodec_data
->mAudio_Ana_DevicePower
[i
] == true)
2420 static bool TurnOnADcPowerACC(int ADCType
, bool enable
)
2422 bool refmic_using_ADC_L
;
2423 CHIP_SW_VER ver
= mt_get_chip_sw_ver();
2424 if (CHIP_SW_VER_02
<= ver
)
2426 refmic_using_ADC_L
= false;
2428 else if (CHIP_SW_VER_01
>= ver
)
2430 refmic_using_ADC_L
= true;
2434 refmic_using_ADC_L
= false;
2437 printk("%s ADCType = %d enable = %d, ver=%d, refmic_using_ADC_L=%d \n", __func__
, ADCType
, enable
, ver
, refmic_using_ADC_L
);
2440 //uint32 ULIndex = GetULFrequency(mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC]);
2441 uint32 SampleRate_VUL1
= mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
];
2442 //uint32 SampleRate_VUL2 = mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC_2];
2446 MicbiasRef
= Ana_Get_Reg(AUDENC_ANA_CON9
) & 0x0700; // save current micbias ref set by accdet
2447 printk("MicbiasRef=0x%x \n", MicbiasRef
);
2450 if (GetAdcStatus() == false)
2452 audckbufEnable(true);
2453 Ana_Set_Reg(LDO_VCON1
, 0x0301, 0xffff); //VA28 remote sense
2454 Ana_Set_Reg(LDO_CON2
, 0x8102, 0xffff); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on)
2457 //ClsqAuxEnable(true);
2460 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0004, 0x0004); //Enable audio ADC CLKGEN
2461 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //ADC CLK from CLKGEN (13MHz)
2462 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0104, 0x0104); //Enable LCLDO_ENC 1P8V
2463 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense
2464 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff); //default value
2465 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0xffff); //default value
2468 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2470 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2472 SetDCcoupleNP(AUDIO_MIC_BIAS0
, mAudio_Analog_Mic1_mode
); //micbias0 DCCopuleNP
2473 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0201, 0xff09); //Enable MICBIAS0, MISBIAS0 = 1P9V
2474 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0211, 0xff19); //Enable MICBIAS0, MISBIAS0 = 1P9V, also enable MICBIAS1 at the same time to avoid noise
2476 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2478 SetDCcoupleNP(AUDIO_MIC_BIAS1
, mAudio_Analog_Mic1_mode
); //micbias1 DCCopuleNP
2479 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0710, 0xff90); //Enable MICBIAS1, MISBIAS1 = 2P5V
2481 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x000f); //Audio L PGA 18 dB gain(SMT)
2483 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2485 SetDCcoupleNP(AUDIO_MIC_BIAS0
, mAudio_Analog_Mic2_mode
); //micbias0 DCCopuleNP
2486 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0201, 0xff09); //Enable MICBIAS0, MISBIAS0 = 1P9V
2487 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0211, 0xff19); //Enable MICBIAS0, MISBIAS0 = 1P9V, also enable MICBIAS1 at the same time to avoid noise
2488 if (refmic_using_ADC_L
== false)
2490 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0030, 0x00f0); //Audio R PGA 18 dB gain(SMT)
2494 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x000f); //Audio L PGA 18 dB gain(SMT)
2498 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2500 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0800, 0xf900); //PGA stb enhance
2502 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2504 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0041, 0x00C1); //Audio L preamplifier input sel : AIN0. Enable audio L PGA
2505 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0541, 0xffff); //Audio L ADC input sel : L PGA. Enable audio L ADC
2507 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2509 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0500, 0xffff); //Audio L ADC input sel : L PGA. Enable audio L ADC
2510 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0581, 0xffff); //Audio L preamplifier input sel : AIN1. Enable audio L PGA
2514 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2516 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0800, 0xf900); //PGA stb enhance
2517 if (refmic_using_ADC_L
== false)
2519 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C1, 0x00C1); //Audio R preamplifier input sel : AIN2. Enable audio R PGA
2520 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x05C1, 0xffff); //Audio R ADC input sel : R PGA. Enable audio R ADC
2524 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x00c1, 0x00C1); //Audio L preamplifier input sel : AIN2. Enable audio L PGA
2525 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x05c1, 0xffff); //Audio L ADC input sel : L PGA. Enable audio L ADC
2531 if (GetAdcStatus() == false)
2533 //here to set digital part
2535 //AdcClockEnable(true);
2536 if ((GetDacStatus() == false))
2538 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x005a, 0xffff); //power on clock
2542 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0000, 0xffff); //power on clock
2544 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, 0x0000, 0xffff); //configure ADC setting
2545 //Ana_Set_Reg(AFUNC_AUD_CON2, 0x0006, 0xffff); //sdm audio fifo clock power on
2546 //Ana_Set_Reg(AFUNC_AUD_CON0, 0xc3a1, 0xffff); //scrambler clock on enable
2547 //Ana_Set_Reg(AFUNC_AUD_CON2, 0x0003, 0xffff); //sdm power on
2548 //Ana_Set_Reg(AFUNC_AUD_CON2, 0x000b, 0xffff); //sdm fifo enable
2549 //Ana_Set_Reg(AFE_DL_SDM_CON1, 0x001e, 0xffff); //set attenuation gain
2550 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0001, 0xffff); //[0] afe enable
2552 Ana_Set_Reg(AFE_UL_SRC0_CON0_H
, (ULSampleRateTransform(SampleRate_VUL1
) << 3 | ULSampleRateTransform(SampleRate_VUL1
) << 1) , 0x001f); //UL sample rate and mode configure
2553 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0001, 0xffff); //UL turn on
2558 if (GetAdcStatus() == false)
2560 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0000, 0xffff); //UL turn off
2561 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0020, 0x0020); //up-link power down
2563 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2565 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2567 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0041, 0xffff); //Audio L ADC input sel : off, disable audio L ADC
2568 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2569 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x000f); //Audio L PGA 0 dB gain
2570 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0xffff); //Audio L preamplifier input sel : off, disable audio L PGA
2572 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2574 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0500, 0xffff); //Audio L preamplifier input sel : off, disable audio L PGA
2575 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0xffff); //Audio L ADC input sel : off, disable audio L ADC
2576 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2577 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x000f); //Audio L PGA 0 dB gain
2580 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0xffff); //
2581 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff); //
2583 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2585 //Ana_Set_Reg(AUDENC_ANA_CON9, (MicbiasRef|0x0000), 0xff09); //disable MICBIAS0, restore to micbias set by accdet
2586 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff19); //disable MICBIAS0 and MICBIAS1, restore to micbias set by accdet
2588 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2590 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff90); //disable MICBIAS1, restore to micbias set by accdet
2593 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2595 if (refmic_using_ADC_L
== false)
2597 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C1, 0xffff); //Audio R ADC input sel : off, disable audio R ADC
2598 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2599 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x00f0); //Audio R PGA 0 dB gain
2600 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0000, 0xffff); //Audio R preamplifier input sel : off, disable audio R PGA
2604 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x00c1, 0xffff); //Audio L ADC input sel : off, disable audio L ADC
2605 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2606 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x000f); //Audio L PGA 0 dB gain
2607 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0xffff); //Audio L preamplifier input sel : off, disable audio L PGA
2609 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0xffff); //
2610 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff); //
2612 //Ana_Set_Reg(AUDENC_ANA_CON9, (MicbiasRef|0x0000), 0xff09); //disable MICBIAS0, restore to micbias set by accdet
2613 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff19); //disable MICBIAS0 and MICBIAS1, restore to micbias set by accdet
2615 if (GetAdcStatus() == false)
2617 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off
2618 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0004, 0x0104); //disable LCLDO_ENC 1P8V
2619 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //disable ADC CLK from CLKGEN (13MHz)
2620 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0104); //disable audio ADC CLKGEN
2622 if (GetDLStatus() == false)
2624 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0000, 0xffff); //afe disable
2625 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0084, 0x0084); //afe power down and total audio clk disable
2628 //AdcClockEnable(false);
2629 Topck_Enable(false);
2630 //ClsqAuxEnable(false);
2633 audckbufEnable(false);
2641 static bool TurnOnADcPowerDmic(int ADCType
, bool enable
)
2643 printk("%s ADCType = %d enable = %d \n", __func__
, ADCType
, enable
);
2646 uint32 ULIndex
= GetULFrequency(mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
]);
2647 uint32 SampleRate_VUL1
= mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
];
2648 //uint32 SampleRate_VUL2 = mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC_2];
2652 MicbiasRef
= Ana_Get_Reg(AUDENC_ANA_CON9
) & 0x0700; // save current micbias ref set by accdet
2653 printk("MicbiasRef=0x%x \n", MicbiasRef
);
2657 if (GetAdcStatus() == false)
2659 audckbufEnable(true);
2660 Ana_Set_Reg(LDO_CON2
, 0x8102, 0xffff); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on)
2663 //ClsqAuxEnable(true);
2666 SetDCcoupleNP(AUDIO_MIC_BIAS0
, mAudio_Analog_Mic1_mode
); //micbias0 DCCopuleNP
2667 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0201, 0xff09); //Enable MICBIAS0, MISBIAS0 = 1P9V
2668 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0211, 0xff19); //Enable MICBIAS0 and MICBIAS1, MISBIAS0 = 1P9V
2669 Ana_Set_Reg(AUDENC_ANA_CON8
, 0x0005, 0xffff); //DMIC enable
2671 //here to set digital part
2673 //AdcClockEnable(true);
2674 if ((GetDacStatus() == false))
2676 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x005a, 0xffff); //power on clock
2680 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0000, 0xffff); //power on clock
2682 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, (ULIndex
<< 7) | (ULIndex
<< 6), 0xffff); //dmic sample rate, ch1 and ch2 set to 3.25MHz 48k
2683 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0001, 0xffff); //[0] afe enable
2685 Ana_Set_Reg(AFE_UL_SRC0_CON0_H
, (ULSampleRateTransform(SampleRate_VUL1
) << 3 | ULSampleRateTransform(SampleRate_VUL1
) << 1) , 0x001f); //UL sample rate and mode configure
2686 Ana_Set_Reg(AFE_UL_SRC0_CON0_H
, 0x00e0 , 0xffe0); //2-wire dmic mode, ch1 and ch2 digital mic ON
2687 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0003, 0xffff); //digmic input mode 3.25MHz, select SDM 3-level mode, UL turn on
2692 if (GetAdcStatus() == false)
2694 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0000, 0xffff); //UL turn off
2695 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0020, 0x0020); //up-link power down
2697 Ana_Set_Reg(AUDENC_ANA_CON8
, 0x0000, 0xffff); //DMIC disable
2699 //Ana_Set_Reg(AUDENC_ANA_CON9, (MicbiasRef|0x0000), 0xff09); //MICBIAS0(1.7v), powen down, restore to micbias set by accdet
2700 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff19); //MICBIAS0(1.7v), powen down, restore to micbias set by accdet, MICBIAS1 off
2701 if (GetDLStatus() == false)
2703 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0000, 0xffff); //afe disable
2704 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0084, 0x0084); //afe power down and total audio clk disable
2707 //AdcClockEnable(false);
2708 Topck_Enable(false);
2709 //ClsqAuxEnable(false);
2712 audckbufEnable(false);
2720 static bool TurnOnADcPowerDCC(int ADCType
, bool enable
)
2722 printk("%s ADCType = %d enable = %d \n", __func__
, ADCType
, enable
);
2725 //uint32 ULIndex = GetULFrequency(mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC]);
2726 uint32 SampleRate_VUL1
= mBlockSampleRate
[AUDIO_ANALOG_DEVICE_IN_ADC
];
2727 //uint32 SampleRate_VUL2 = mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC_2];
2731 MicbiasRef
= Ana_Get_Reg(AUDENC_ANA_CON9
) & 0x0700; // save current micbias ref set by accdet
2732 printk("MicbiasRef=0x%x \n", MicbiasRef
);
2736 if (GetAdcStatus() == false)
2738 audckbufEnable(true);
2739 Ana_Set_Reg(LDO_VCON1
, 0x0301, 0xffff); //VA28 remote sense
2740 Ana_Set_Reg(LDO_CON2
, 0x8102, 0xffff); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on)
2743 //ClsqAuxEnable(true);
2746 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0004, 0x0004); //Enable audio ADC CLKGEN
2747 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //ADC CLK from CLKGEN (13MHz)
2748 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0104, 0x0104); //Enable LCLDO_ENC 1P8V
2750 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense
2752 //DCC 50k CLK(from 26M
2753 Ana_Set_Reg(TOP_CLKSQ_SET
, 0x0003, 0x0003); //
2754 Ana_Set_Reg(TOP_CKPDN_CON0
, 0x0000, 0x2000); //bit[13] AUD_CK power down=0
2756 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0x0002); //dcclk_div=11'b00100000011, dcclk_ref_ck_sel=2'b00
2757 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2060, 0xffff); //dcclk_pdn=1'b0
2758 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2061, 0xffff); //dcclk_gen_on=1'b1
2760 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff); //default value
2761 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0xffff); //default value
2763 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2765 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2767 SetDCcoupleNP(AUDIO_MIC_BIAS0
, mAudio_Analog_Mic1_mode
); //micbias0 DCCopuleNP
2768 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0201, 0xff09); //Enable MICBIAS0, MISBIAS0 = 1P9V
2769 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0211, 0xff19); //Enable MICBIAS0 and MICBIAS1, MISBIAS0 = 1P9V
2770 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0207, 0xff0f); //MICBIAS0 DCC SwithP/N on //DCC
2771 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0004, 0xffff); //Audio L preamplifier DCC precharge
2772 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0045, 0xffff); //Audio L preamplifier input sel : AIN0. Enable audio L PGA
2773 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0002, 0x000f); //Audio L PGA 12 dB gain
2774 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0047, 0xffff); //Audio L preamplifier DCCEN
2776 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2778 SetDCcoupleNP(AUDIO_MIC_BIAS1
, mAudio_Analog_Mic1_mode
); //micbias1 DCCopuleNP
2779 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0710, 0xff90); //Enable MICBIAS1, MISBIAS1 = 2P5V
2780 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0770, 0xfff0); //MICBIAS1 DCC SwithP/N on //DCC
2781 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0004, 0xffff); //Audio L preamplifier DCC precharge
2782 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0085, 0xffff); //Audio L preamplifier input sel : AIN1. Enable audio L PGA
2783 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0002, 0x000f); //Audio L PGA 12 dB gain
2784 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0087, 0xffff); //Audio L preamplifier DCCEN
2787 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2789 SetDCcoupleNP(AUDIO_MIC_BIAS0
, mAudio_Analog_Mic2_mode
); //micbias0 DCCopuleNP
2790 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0201, 0xff09); //Enable MICBIAS0, MISBIAS0 = 1P9V
2791 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0211, 0xff19); //Enable MICBIAS0 and MICBIAS1, MISBIAS0 = 1P9V
2792 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0207, 0xff0f); //MICBIAS0 DCC SwithP/N on //DCC
2793 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0004, 0xffff); //Audio R preamplifier DCC precharge
2794 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C5, 0xffff); //Audio R preamplifier input sel : AIN2. Enable audio R PGA
2795 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0020, 0x00f0); //Audio R PGA 12 dB gain
2796 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C7, 0xffff); //Audio R preamplifier DCCEN
2799 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0800, 0xf900); //PGA stb enhance
2801 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2804 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2806 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0547, 0xffff); //Audio L ADC input sel : L PGA. Enable audio L ADC
2808 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0543, 0xffff); //Audio L preamplifier DCC precharge off
2810 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2812 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0587, 0xffff); //Audio L ADC input sel : L PGA. Enable audio L ADC
2814 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0583, 0xffff); //Audio L preamplifier DCC precharge off
2817 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2819 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x05C7, 0xffff); //Audio R ADC input sel : R PGA. Enable audio R ADC
2821 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x05C3, 0xffff); //Audio R preamplifier DCC precharge off
2826 if (GetAdcStatus() == false)
2828 //here to set digital part
2830 //AdcClockEnable(true);
2832 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0000, 0xffff); //Audio system digital clock power down release
2833 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, 0x0000, 0xffff); //configure ADC setting
2834 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0001, 0xffff); //[0] afe enable
2836 Ana_Set_Reg(AFE_UL_SRC0_CON0_H
, (ULSampleRateTransform(SampleRate_VUL1
) << 3 | ULSampleRateTransform(SampleRate_VUL1
) << 1) , 0x001f); //UL sample rate and mode configure
2837 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0001, 0xffff); //UL turn on
2842 if (GetAdcStatus() == false)
2844 Ana_Set_Reg(AFE_UL_SRC0_CON0_L
, 0x0000, 0xffff); //UL turn off
2845 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0020, 0x0020); //up-link power down
2847 if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC1
) //main and headset mic
2849 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2851 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0043, 0xffff); //Audio L ADC input sel : off, disable audio L ADC
2852 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2853 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0041, 0xffff); //Audio L preamplifier DCCEN disable
2854 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x000f); //Audio L PGA 0 dB gain
2855 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0xffff); //Audio L preamplifier input sel : off, disable audio L PGA
2857 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2859 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0083, 0xffff); //Audio L preamplifier input sel : off, disable audio L PGA
2860 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2861 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0081, 0xffff); //Audio L preamplifier DCCEN disable
2862 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x000f); //Audio L PGA 0 dB gain
2863 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0xffff); //Audio L ADC input sel : off, disable audio L ADC
2866 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0xffff); //
2867 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff); //
2869 if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 0) //"ADC1", main_mic
2871 //Ana_Set_Reg(AUDENC_ANA_CON9, (MicbiasRef|0x0000), 0xff09); //disable MICBIAS0, restore to micbias set by accdet
2872 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff19); //disable MICBIAS0 and MICBIAS1, restore to micbias set by accdet
2874 else if (mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] == 1) //"ADC2", headset mic
2876 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff90); //disable MICBIAS1, restore to micbias set by accdet
2879 else if (ADCType
== AUDIO_ANALOG_DEVICE_IN_ADC2
) //ref mic
2881 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C3, 0xffff); //Audio R ADC input sel : off, disable audio R ADC
2882 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //PGA stb enhance off
2883 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C1, 0xffff); //Audio R preamplifier DCCEN disable
2884 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x00f0); //Audio R PGA 0 dB gain
2885 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0000, 0xffff); //Audio R preamplifier input sel : off, disable audio R PGA
2887 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0xffff); //
2888 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff); //
2889 //Ana_Set_Reg(AUDENC_ANA_CON9, (MicbiasRef|0x0000), 0xff09); //disable MICBIAS0, restore to micbias set by accdet
2890 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0xff19); //disable MICBIAS0 and MICBIAS1, restore to micbias set by accdet
2893 if (GetAdcStatus() == false)
2895 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2060, 0xffff); //dcclk_gen_on=1'b0
2896 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0x0002); //dcclk_pdn=1'b0
2898 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off
2899 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0004, 0x0104); //disable LCLDO_ENC 1P8V
2900 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0xffff); //disable ADC CLK from CLKGEN (13MHz)
2901 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0104); //disable audio ADC CLKGEN
2903 if (GetDLStatus() == false)
2905 Ana_Set_Reg(AFE_UL_DL_CON0
, 0x0000, 0xffff); //afe disable
2906 Ana_Set_Reg(AFE_AUDIO_TOP_CON0
, 0x0084, 0x0084); //afe power down and total audio clk disable
2909 //AdcClockEnable(false);
2910 Topck_Enable(false);
2911 //ClsqAuxEnable(false);
2914 audckbufEnable(false);
2923 static bool TurnOnADcPowerDCCECM(int ADCType
, bool enable
)
2925 //use TurnOnADcPowerDCC() with SetDCcoupleNP() setting ECM or not depending on mAudio_Analog_Mic1_mode/mAudio_Analog_Mic2_mode
2926 TurnOnADcPowerDCC(ADCType
, enable
);
2930 static bool TurnOnVOWDigitalHW(bool enable
)
2932 printk("%s enable = %d \n", __func__
, enable
);
2935 //move to vow driver
2936 #ifdef VOW_STANDALONE_CONTROL
2937 if (mAudio_VOW_Mic_type
== AUDIO_VOW_MIC_TYPE_Handset_DMIC
)
2939 Ana_Set_Reg(AFE_VOW_TOP
, 0x6850, 0xffff); //VOW enable
2943 Ana_Set_Reg(AFE_VOW_TOP
, 0x4810, 0xffff); //VOW enable
2949 //disable VOW interrupt here
2950 //Ana_Set_Reg(INT_CON0, 0x0015, 0x0800); //disable VOW interrupt. BIT11
2951 #ifdef VOW_STANDALONE_CONTROL
2952 //move to vow driver
2954 Ana_Set_Reg(AFE_VOW_TOP
, 0x4010, 0xffff); //VOW disable
2955 Ana_Set_Reg(AFE_VOW_TOP
, 0xC010, 0xffff); //VOW clock power down
2961 static bool TurnOnVOWADcPowerACC(int MicType
, bool enable
)
2964 printk("%s MicType = %d enable = %d, mIsVOWOn=%d, mAudio_VOW_Mic_type=%d \n", __func__
, MicType
, enable
, mIsVOWOn
, mAudio_VOW_Mic_type
);
2965 //already on, no need to set again
2966 if (enable
== mIsVOWOn
)
2972 ret
= GetGPIO_Info(4, &pin_vowclk
, &pin_mode_vowclk
);
2975 printk("TurnOnVOWADcPowerACC GetGPIO_Info FAIL1!!! \n");
2979 ret
= GetGPIO_Info(2, &pin_audmiso
, &pin_mode_audmiso
);
2982 printk("TurnOnVOWADcPowerACC GetGPIO_Info FAIL2!!! \n");
2990 SetVOWStatus(mIsVOWOn
);
2991 #if defined(VOW_TONE_TEST)
2992 OpenAfeDigitaldl1(false);
2993 OpenAnalogHeadphone(false);
2994 EnableSideGenHw(Soc_Aud_InterConnectionOutput_O03
, Soc_Aud_InterConnectionOutput_Num_Output
, false);
2997 //uint32 ULIndex = GetULFrequency(mBlockSampleRate[AUDIO_ANALOG_DEVICE_IN_ADC]);
3001 MicbiasRef
= Ana_Get_Reg(AUDENC_ANA_CON9
) & 0x0700; // save current micbias ref set by accdet
3002 printk("MicbiasRef=0x%x \n", MicbiasRef
);
3008 case AUDIO_VOW_MIC_TYPE_Headset_MIC
:
3009 printk("%s, case AUDIO_VOW_MIC_TYPE_Headset_MIC \n", __func__
);
3012 Ana_Set_Reg(LDO_VCON1
, 0x0301, 0x0200); //VA28 remote sense, only set bit9, RG_VAUD28_SENSE_SEL
3013 Ana_Set_Reg(LDO_CON2
, 0x8103, 0x000f); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET Enable low power mode. bit0~3
3014 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0003, 0x0003); //Enable audio uplink VOW LPW globe bias, Enable audio uplink LPW mode. bit0~1
3015 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x0409, 0x040D); //Enable fbdiv relatch (low jitter), Set DCKO = 1/4 F_PLL, Enable VOWPLL CLK. bit:0,2,3,10
3016 Ana_Set_Reg(AUDENC_ANA_CON14
, 0x0000, 0x0038); //PLL VCOBAND. bit5:3
3017 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x06F9, 0x03f0); //PLL devider ratio. bit9:4
3018 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x8180, 0x8000); //PLL low power. bit:15
3019 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz), Enable Audio ADC FBDAC 0.25FS LPW. BIT0,2,3
3020 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0100, 0x0100); //Enable LCLDO_ENC 1P8V. BIT8
3021 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense.BIT1,2
3022 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff);
3023 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0x0800);//BIT11
3024 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0F10, 0x0f10); //Enable MICBIAS1 lowpower mode, MISBIAS1 = 2P5V.BIT4,10~8,11
3025 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0081, 0x00C1); //Audio L preamplifier input sel : AIN0, Enable audio L PGA. BIT0,7:6
3026 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x0007); //Audio L PGA 18 dB gain. BIT:2:0
3027 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0809, 0xf900); //PGA stb enhance. BIT:8,15:11
3028 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0581, 0x0500); //Audio L ADC input sel : L PGA, Enable audio L ADC.BIT:8,9,10
3030 //here to set digital part
3031 //Ana_Set_Reg(TOP_CKPDN_CON0, 0x6EFC, 0xffff); //VOW clock power down disable
3032 VOW12MCK_Enable(true);
3034 //need to enable VOW interrpt
3035 //Ana_Set_Reg(INT_CON0, 0x0815, 0x0800); //enable VOW interrupt. BIT:11
3038 #ifdef MTK_VOW_SUPPORT
3040 //Enable VOW_CLK_MISO
3041 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_01
); //GPIO148: mode 1
3042 //Enable VOW_DAT_MISO
3043 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_02
); //GPIO25: mode 2
3045 //Enable VOW_CLK_MISO
3046 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_01
); //GPIO148: mode 1
3047 //Enable VOW_DAT_MISO
3048 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_02
); //GPIO25: mode 2
3052 Ana_Set_Reg(GPIO_MODE3
, 0x1251, 0xffff); //GPIO Set to VOW data
3056 case AUDIO_VOW_MIC_TYPE_Handset_DMIC
:
3057 case AUDIO_VOW_MIC_TYPE_Handset_DMIC_800K
:
3058 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_DMIC \n", __func__
);
3061 Ana_Set_Reg(LDO_CON2
, 0x8103, 0x000f); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET Enable low power mode. bit0~3
3062 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x0719, 0x040D); //Enable fbdiv relatch (low jitter), Set DCKO = 1/4 F_PLL, Enable VOWPLL CLK. bit:0,2,3,10
3063 Ana_Set_Reg(AUDENC_ANA_CON14
, 0x0000, 0x0038); //PLL VCOBAND. bit5:3
3064 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x06F9, 0x03f0); //PLL devider ratio. bit9:4
3065 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x8180, 0x8000); //PLL low power. bit:15
3066 //no need to config this reg due to VOW no need
3067 //NvregEnable(false); //Disable audio globe bias (Default on)
3068 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0002, 0x0002); //Enable audio uplink VOW LPW globe bias. BIT1
3069 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0A01, 0x0F01); //Enable MICBIAS0 lowpower mode, MISBIAS0 = 1P9V..BIT0,10~8,11
3070 Ana_Set_Reg(AUDENC_ANA_CON8
, 0x0005, 0x0007); //DMIC enable.BIT0~2
3072 //here to set digital part
3073 //Ana_Set_Reg(TOP_CKPDN_CON0, 0x6EFC, 0xffff); //VOW clock power down disable
3074 VOW12MCK_Enable(true);
3076 //need to enable VOW interrpt
3077 //Ana_Set_Reg(INT_CON0, 0x0815, 0x0800); //enable VOW interrupt. BIT:11
3079 #ifdef MTK_VOW_SUPPORT
3081 //Enable VOW_CLK_MISO
3082 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_01
); //GPIO148: mode 1
3083 //Enable VOW_DAT_MISO
3084 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_02
); //GPIO25: mode 2
3087 //Enable VOW_CLK_MISO
3088 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_01
); //GPIO148: mode 1
3089 //Enable VOW_DAT_MISO
3090 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_02
); //GPIO25: mode 2
3094 Ana_Set_Reg(GPIO_MODE3
, 0x1251, 0xffff); //GPIO Set to VOW data
3097 case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCC
:
3098 case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCCECM
:
3099 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCC \n", __func__
);
3102 Ana_Set_Reg(LDO_VCON1
, 0x0200, 0x0200); //VA28 remote sense, only set bit9, RG_VAUD28_SENSE_SEL
3103 Ana_Set_Reg(LDO_CON2
, 0x0003, 0x000f); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET Enable low power mode. bit0~3
3104 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0003, 0x0003); //Enable audio uplink VOW LPW globe bias, Enable audio uplink LPW mode. bit0~1
3105 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x0409, 0x040D); //Enable fbdiv relatch (low jitter), Set DCKO = 1/4 F_PLL, Enable VOWPLL CLK. bit:0,2,3,10
3106 Ana_Set_Reg(AUDENC_ANA_CON14
, 0x0000, 0x0038); //PLL VCOBAND. bit5:3
3107 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x06F9, 0x03f0); //PLL devider ratio. bit9:4
3108 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x8180, 0x8000); //PLL low power. bit:15
3111 VOW12MCK_Enable(true);
3113 Ana_Set_Reg(AFE_VOW_TOP
, 0x4000, 0x8000); //pdn_vow=1'b0.BIT15
3114 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3115 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2066, 0xffff);
3116 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2064, 0xffff);
3117 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2065, 0xffff);
3119 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff);
3120 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0x0800);//BIT11
3121 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz), Enable Audio ADC FBDAC 0.25FS LPW.BIT0,2,3
3122 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0100, 0x0100); //Enable LCLDO_ENC 1P8V
3123 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense
3124 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0A01, 0x0f01); //Enable MICBIAS0 lowpower mode, MISBIAS0 = 1P9V.BIT0,10~8,11
3125 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0A07, 0xffff); //MICBIAS0 DCC SwithP/N on
3126 if (MicType
== AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCCECM
) //ECM dual diff mode
3128 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0A07, 0x0006); //MICBIAS0 DCC SwithP/N on.BIT1,2
3130 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0004, 0x0004); //Audio L preamplifier DCC precharge.BIT2
3131 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0045, 0x00C1); //Audio L preamplifier input sel : AIN0,Enable audio L PGA.BIT0,6,7
3132 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x0007); //Audio L PGA 18 dB gain.BIT0~2
3133 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0047, 0x0002); //Audio L preamplifier DCCEN.BIT1
3134 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0809, 0xf800); //PGA stb enhance. BIT11~15
3135 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0547, 0x0700); //Audio L ADC input sel : L PGA, Enable audio L ADC.BIT8,9,10
3138 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0543, 0x0004); //Audio L preamplifier DCC precharge off. BIT2=0
3140 //here set digital part
3142 //need to enable VOW interrpt
3143 //Ana_Set_Reg(INT_CON0, 0x0815, 0x0800); //enable VOW interrupt. BIT:11
3146 #ifdef MTK_VOW_SUPPORT
3148 //Enable VOW_CLK_MISO
3149 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_01
); //GPIO148: mode 1
3150 //Enable VOW_DAT_MISO
3151 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_02
); //GPIO25: mode 2
3154 //Enable VOW_CLK_MISO
3155 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_01
); //GPIO148: mode 1
3156 //Enable VOW_DAT_MISO
3157 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_02
); //GPIO25: mode 2
3161 Ana_Set_Reg(GPIO_MODE3
, 0x1251, 0xffff); //GPIO Set to VOW data
3165 case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCC
:
3166 case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCCECM
:
3167 printk("%s, case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCC \n", __func__
);
3170 Ana_Set_Reg(LDO_VCON1
, 0x0200, 0x0200); //VA28 remote sense, only set bit9, RG_VAUD28_SENSE_SEL
3171 Ana_Set_Reg(LDO_CON2
, 0x0003, 0x000f); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET Enable low power mode. bit0~3
3172 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0003, 0x0003); //Enable audio uplink VOW LPW globe bias, Enable audio uplink LPW mode. bit0~1
3173 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x0409, 0x040D); //Enable fbdiv relatch (low jitter), Set DCKO = 1/4 F_PLL, Enable VOWPLL CLK. bit:0,2,3,10
3174 Ana_Set_Reg(AUDENC_ANA_CON14
, 0x0000, 0x0038); //PLL VCOBAND. bit5:3
3175 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x06F9, 0x03f0); //PLL devider ratio. bit9:4
3176 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x8180, 0x8000); //PLL low power. bit:15
3179 VOW12MCK_Enable(true);
3182 Ana_Set_Reg(AFE_VOW_TOP
, 0x4000, 0x8000); //pdn_vow=1'b0.BIT15
3183 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3184 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2066, 0xffff);
3185 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2064, 0xffff);
3186 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2065, 0xffff);
3189 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff);
3190 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0x0800);//BIT11
3191 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz), Enable Audio ADC FBDAC 0.25FS LPW.BIT0,2,3
3192 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0100, 0x0100); //Enable LCLDO_ENC 1P8V
3193 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense
3194 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0F10, 0x0f10); //Enable MICBIAS1 lowpower mode, MISBIAS1 = 2P5V.BIT:4,8:11
3196 if (MicType
== AUDIO_VOW_MIC_TYPE_Headset_MIC_DCCECM
)
3198 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0F20, 0x0060); //MICBIAS1 DCC ECM single SwithP/N on(P:1,N:0). BIT5,6
3200 //Ana_Set_Reg(AUDENC_ANA_CON9, 0x0F70, 0xffff); //MICBIAS1 DCC SwithP/N on
3201 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0004, 0x0004); //Audio L preamplifier DCC precharge.BIT2
3202 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0045, 0x00C1); //Audio L preamplifier input sel : AIN0,Enable audio L PGA.BIT0,6,7
3203 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x0007); //Audio L PGA 18 dB gain.BIT0~2
3204 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0047, 0x0002); //Audio L preamplifier DCCEN.BIT1
3205 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0809, 0xf800); //PGA stb enhance. BIT11~15
3206 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0547, 0x0700); //Audio L ADC input sel : L PGA, Enable audio L ADC.BIT8,9,10
3209 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0543, 0x0004); //Audio L preamplifier DCC precharge off. BIT2=0
3212 //here set digital part
3213 VOW12MCK_Enable(true);
3215 //need to enable VOW interrpt
3216 //Ana_Set_Reg(INT_CON0, 0x0815, 0x0800); //enable VOW interrupt. BIT:11
3219 #ifdef MTK_VOW_SUPPORT
3221 //Enable VOW_CLK_MISO
3222 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_01
); //GPIO148: mode 1
3223 //Enable VOW_DAT_MISO
3224 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_02
); //GPIO25: mode 2
3227 //Enable VOW_CLK_MISO
3228 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_01
); //GPIO148: mode 1
3229 //Enable VOW_DAT_MISO
3230 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_02
); //GPIO25: mode 2
3234 Ana_Set_Reg(GPIO_MODE3
, 0x1251, 0xffff); //GPIO Set to VOW data
3238 case AUDIO_VOW_MIC_TYPE_Handset_AMIC
:
3240 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_AMIC \n", __func__
);
3243 Ana_Set_Reg(LDO_VCON1
, 0x0200, 0x0200); //VA28 remote sense, only set bit9, RG_VAUD28_SENSE_SEL
3244 Ana_Set_Reg(LDO_CON2
, 0x0003, 0x000f); // LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET Enable low power mode. bit0~3
3245 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0003, 0x0003); //Enable audio uplink VOW LPW globe bias, Enable audio uplink LPW mode. bit0~1
3246 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x0409, 0x040D); //Enable fbdiv relatch (low jitter), Set DCKO = 1/4 F_PLL, Enable VOWPLL CLK. bit:0,2,3,10
3247 Ana_Set_Reg(AUDENC_ANA_CON14
, 0x0000, 0x0038); //PLL VCOBAND. bit5:3
3248 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x06F9, 0x03f0); //PLL devider ratio. bit9:4
3249 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x8180, 0x8000); //PLL low power. bit:15
3250 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz), Enable Audio ADC FBDAC 0.25FS LPW. BIT0,2,3
3251 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0100, 0x0100); //Enable LCLDO_ENC 1P8V
3252 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0006, 0x0006); //LCLDO_ENC remote sense
3253 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x1515, 0xffff);
3254 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0800, 0x0800);//BIT11
3255 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0A01, 0x0f01); //Enable MICBIAS0 lowpower mode, MISBIAS0 = 1P9V.BIT0,10~8,11
3256 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0041, 0x00C1); //Audio L preamplifier input sel : AIN0, Enable audio L PGA. BIT0,7:6
3257 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0003, 0x0007); //Audio L PGA 18 dB gain. BIT:2:0
3258 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0809, 0xf900); //PGA stb enhance. BIT:8,15:11
3259 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0541, 0x0500); //Audio L ADC input sel : L PGA, Enable audio L ADC.BIT:8,9,10
3261 //here to set digital part
3262 //Ana_Set_Reg(TOP_CKPDN_CON0, 0x6EFC, 0xffff); //VOW clock power down disable
3263 VOW12MCK_Enable(true);
3265 //need to enable VOW interrpt
3266 //Ana_Set_Reg(INT_CON0, 0x0815, 0x0800); //enable VOW interrupt. BIT:11
3269 #ifdef MTK_VOW_SUPPORT
3271 //Enable VOW_CLK_MISO
3272 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_01
); //GPIO148: mode 1
3273 //Enable VOW_DAT_MISO
3274 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_02
); //GPIO25: mode 2
3277 //Enable VOW_CLK_MISO
3278 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_01
); //GPIO148: mode 1
3279 //Enable VOW_DAT_MISO
3280 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_02
); //GPIO25: mode 2
3284 Ana_Set_Reg(GPIO_MODE3
, 0x1251, 0xffff); //GPIO Set to VOW data
3289 //[Todo]Enable VOW INT (has alredy done in pmic.c)
3290 //enable VOW INT in pmic driver
3293 //Ana_Set_Reg(AFE_VOW_CFG0, reg_AFE_VOW_CFG0, 0xffff); //VOW AMPREF Setting, set by MD32 after DC calibration
3294 Ana_Set_Reg(AFE_VOW_CFG1
, reg_AFE_VOW_CFG1
, 0xffff); //VOW A,B timeout initial value
3295 if (MicType
== AUDIO_VOW_MIC_TYPE_Handset_DMIC
) //1p6M
3297 Ana_Set_Reg(AFE_VOW_POSDIV_CFG0
, 0x0B00, 0xffff);
3299 else if (MicType
== AUDIO_VOW_MIC_TYPE_Handset_DMIC_800K
)
3301 Ana_Set_Reg(AFE_VOW_POSDIV_CFG0
, 0x0B08, 0xffff);
3303 Ana_Set_Reg(AFE_VOW_CFG2
, reg_AFE_VOW_CFG2
, 0xffff); //VOW A,B value setting
3304 Ana_Set_Reg(AFE_VOW_CFG3
, reg_AFE_VOW_CFG3
, 0xffff); //alhpa and beta K value setting
3305 Ana_Set_Reg(AFE_VOW_CFG4
, reg_AFE_VOW_CFG4
, 0xffff); //gamma K value setting
3306 Ana_Set_Reg(AFE_VOW_CFG5
, reg_AFE_VOW_CFG5
, 0xffff); //N mini value setting
3309 #ifndef VOW_STANDALONE_CONTROL
3310 if (MicType
== AUDIO_VOW_MIC_TYPE_Handset_DMIC
)
3312 //digital MIC need to config bit13 and bit6, (bit7 need to check) 0x6840
3313 //Ana_Set_Reg(AFE_VOW_TOP, 0x2040, 0x2040); //VOW enable
3314 #if defined (MTK_VOW_SUPPORT)
3315 VowDrv_SetDmicLowPower(false);
3317 Ana_Set_Reg(AFE_VOW_TOP
, 0x20C0, 0x20C0); //VOW enable, with bit7
3319 else if (MicType
== AUDIO_VOW_MIC_TYPE_Handset_DMIC_800K
)
3321 #if defined (MTK_VOW_SUPPORT)
3322 VowDrv_SetDmicLowPower(true);
3324 Ana_Set_Reg(AFE_VOW_TOP
, 0x20C0, 0x20C0); //VOW enable, with bit7
3326 //others setting will do at VOW driver 0x4800
3329 #if defined (MTK_VOW_SUPPORT)
3330 VowDrv_SetDmicLowPower(false);
3332 //Ana_Set_Reg(AFE_VOW_TOP, 0x4810, 0xffff); //VOW enable
3336 #if defined (MTK_VOW_SUPPORT)
3337 //VOW enable, set AFE_VOW_TOP in VOW kernel driver
3338 //need to inform VOW driver mic type
3339 VowDrv_EnableHW(true);
3340 printk("%s, VowDrv_ChangeStatus set\n", __func__
);
3341 VowDrv_ChangeStatus();
3344 #if defined(VOW_TONE_TEST)
3347 OpenAfeDigitaldl1(true);
3348 OpenAnalogHeadphone(true);
3354 #if defined (MTK_VOW_SUPPORT)
3355 //Set VOW driver disable, vow driver will do close all digital part setting
3356 VowDrv_EnableHW(false);
3357 printk("%s, VowDrv_ChangeStatus set\n", __func__
);
3358 VowDrv_ChangeStatus();
3363 case AUDIO_VOW_MIC_TYPE_Headset_MIC
:
3364 printk("%s, case AUDIO_VOW_MIC_TYPE_Headset_MIC close\n", __func__
);
3366 // turn off digital first, move to vow driver
3367 //#ifdef VOW_STANDALONE_CONTROL
3369 //disable VOW interrupt here or when digital power off
3371 #ifdef MTK_VOW_SUPPORT
3373 //Enable VOW_CLK_MISO
3374 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_00
); //GPIO148: mode 0
3375 //Enable VOW_DAT_MISO
3376 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_01
); //GPIO25: mode 1
3379 //GPIO set to back to normal record
3380 //disable VOW_CLK_MISO
3381 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_00
); //GPIO148: mode 0
3383 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_01
); //GPIO25: mode 1
3387 Ana_Set_Reg(GPIO_MODE3
, 0x1249, 0xffff); //GPIO Set to VOW data
3389 VOW12MCK_Enable(false);//VOW clock power down enable
3391 //turn off analog part
3392 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0500, 0x00C1); //Audio L preamplifier input sel : off, disable audio L PGA. BIT:0,6,7
3393 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0700); //Audio L ADC input sel : off, disable audio L ADC.BIT:8,9,10
3394 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0xf900); //PGA stb enhance off,BIT:8,15:11
3395 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x0007); //Audio L PGA 0 dB gain,BIT:0~2
3396 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0x0800); //BIT11
3397 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff);
3399 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0x0f01); //disable MICBIAS0 lowpower mode, MISBIAS0 = 1P7V. BIT:0,8:10,11
3400 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off, BIT:1,2
3401 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0100); //disable LCLDO_ENC 1P8V
3402 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz) off, Enable Audio ADC FBDAC 0.25FS LPW off. BIT:0,2,3
3403 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x0180, 0x8000); //PLL low power off. BIT:15
3404 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x02F0, 0x040D); //disable fbdiv relatch (low jitter),Set DCKO = 1/4 F_PLL off, disable VOWPLL CLK. BIT:0,2,3,10
3405 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0000, 0x0003); //disable audio uplink VOW LPW globe bias, disable audio uplink LPW mode.BIT:0,1
3406 //Ana_Set_Reg(AUDDEC_ANA_CON8, 0x0000, 0xffff); //enable audio globe bias (Default on)
3407 //no need to config this reg due to VOW no need
3408 //NvregEnable(true); //enable audio globe bias (Default on)
3409 Ana_Set_Reg(LDO_CON2
, 0x8102, 0x000f); //LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET, disable low power mode.BIT:0~3
3413 case AUDIO_VOW_MIC_TYPE_Handset_DMIC
:
3414 case AUDIO_VOW_MIC_TYPE_Handset_DMIC_800K
:
3415 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_DMIC close\n", __func__
);
3417 // turn off digital first, move to vow driver
3418 //#ifdef VOW_STANDALONE_CONTROL
3420 //disable VOW interrupt here or when digital power off
3422 #ifdef MTK_VOW_SUPPORT
3424 //Enable VOW_CLK_MISO
3425 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_00
); //GPIO148: mode 0
3426 //Enable VOW_DAT_MISO
3427 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_01
); //GPIO25: mode 1
3430 //GPIO set to back to normal record
3431 //disable VOW_CLK_MISO
3432 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_00
); //GPIO148: mode 0
3434 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_01
); //GPIO25: mode 1
3438 Ana_Set_Reg(GPIO_MODE3
, 0x1249, 0xffff); //GPIO Set to VOW data
3441 VOW12MCK_Enable(false);//VOW clock power down enable
3443 //turn off analog part
3444 Ana_Set_Reg(AUDENC_ANA_CON8
, 0x0000, 0x0007); //DMIC disable.BIT0,1,2
3446 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0x0701); //disable MICBIAS0 lowpower mode, MISBIAS0 = 1P7V.BIT0,8~10
3447 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0000, 0x0002); //disable audio uplink VOW LPW globe bias.BIT1
3448 //no need to config this reg due to VOW no need
3449 //NvregEnable(true); //enable audio globe bias (Default on)
3450 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x0180, 0x8000); //PLL low power off.BIT:15
3451 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x02F0, 0x040D); //disable fbdiv relatch (low jitter),Set DCKO = 1/4 F_PLL off, disable VOWPLL CLK.BIT0,2,3,10
3452 Ana_Set_Reg(LDO_CON2
, 0x8102, 0x000f); //LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET, disable low power mode.BIT:0~3
3456 case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCC
:
3457 case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCCECM
:
3458 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_AMIC_DCC close\n", __func__
);
3460 // turn off digital first, move to vow driver
3461 //#ifdef VOW_STANDALONE_CONTROL
3463 //disable VOW interrupt here or when digital power off
3465 #ifdef MTK_VOW_SUPPORT
3467 //Enable VOW_CLK_MISO
3468 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_00
); //GPIO148: mode 0
3469 //Enable VOW_DAT_MISO
3470 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_01
); //GPIO25: mode 1
3473 //GPIO set to back to normal record
3474 //disable VOW_CLK_MISO
3475 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_00
); //GPIO148: mode 0
3477 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_01
); //GPIO25: mode 1
3481 Ana_Set_Reg(GPIO_MODE3
, 0x1249, 0xffff); //GPIO Set to VOW data
3484 //turn off analog part
3485 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0502, 0x00C1); //Audio L preamplifier input sel : off, disable audio L PGA.BIT0,6,7
3486 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0700); //Audio L ADC input sel : off, disable audio L ADC.BIT:8,9,10
3487 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0xf800); //PGA stb enhance off.BIT11~15
3488 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x0007); //Audio L PGA 0 dB gain.BIT0~2
3489 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0002); //Audio L preamplifier DCCEN.BIT1
3490 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0A01, 0x0006); //MICBIAS0 DCC SwithP/N on.BIT1,2
3491 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0x0800); //BIT11
3492 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff);
3494 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0x0f01); //disable MICBIAS0 lowpower mode, MISBIAS0 = 1P7V. BIT:0,8:10,11
3495 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off, BIT:1,2
3496 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0100); //disable LCLDO_ENC 1P8V
3497 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz) off, Enable Audio ADC FBDAC 0.25FS LPW off. BIT:0,2,3
3498 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2064, 0xffff);
3499 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2066, 0xffff);
3500 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3501 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3503 VOW12MCK_Enable(false);//VOW clock power down enable
3505 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x0180, 0x8000); //PLL low power off. BIT:15
3506 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x02F0, 0x040D); //disable fbdiv relatch (low jitter),Set DCKO = 1/4 F_PLL off, disable VOWPLL CLK. BIT:0,2,3,10
3507 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0000, 0x0003); //disable audio uplink VOW LPW globe bias, disable audio uplink LPW mode.BIT:0,1
3508 //no need to config this reg due to VOW no need
3509 //NvregEnable(true); //enable audio globe bias (Default on)
3510 Ana_Set_Reg(LDO_CON2
, 0x8102, 0x000f); //LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET, disable low power mode.BIT:0~3
3514 case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCC
:
3515 case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCCECM
:
3516 printk("%s, case AUDIO_VOW_MIC_TYPE_Headset_MIC_DCC close\n", __func__
);
3518 // turn off digital first, move to vow driver
3519 //#ifdef VOW_STANDALONE_CONTROL
3521 //disable VOW interrupt here or when digital power off
3523 #ifdef MTK_VOW_SUPPORT
3525 //Enable VOW_CLK_MISO
3526 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_00
); //GPIO148: mode 0
3527 //Enable VOW_DAT_MISO
3528 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_01
); //GPIO25: mode 1
3531 //GPIO set to back to normal record
3532 //disable VOW_CLK_MISO
3533 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_00
); //GPIO148: mode 0
3535 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_01
); //GPIO25: mode 1
3539 Ana_Set_Reg(GPIO_MODE3
, 0x1249, 0xffff); //GPIO Set to VOW data
3542 //turn off analog part
3543 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0502, 0x00C1); //Audio L preamplifier input sel : off, disable audio L PGA.BIT0,6,7
3544 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0700); //Audio L ADC input sel : off, disable audio L ADC.BIT:8,9,10
3545 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0xf800); //PGA stb enhance off.BIT11~15
3546 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x0007); //Audio L PGA 0 dB gain.BIT0~2
3547 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0002); //Audio L preamplifier DCCEN.BIT1
3548 Ana_Set_Reg(AUDENC_ANA_CON9
, 0x0F10, 0x0060); //MICBIAS1 DCC SwithP/N on. BIT5,6
3549 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0x0800); //BIT11
3550 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff);
3552 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0x0f10); //disable MICBIAS0 lowpower mode, MISBIAS0 = 1P7V.BIT4,8:11
3553 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off, BIT:1,2
3554 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0100); //disable LCLDO_ENC 1P8V
3555 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz) off, Enable Audio ADC FBDAC 0.25FS LPW off. BIT:0,2,3
3556 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2064, 0xffff);
3557 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2066, 0xffff);
3558 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3559 Ana_Set_Reg(AFE_DCCLK_CFG0
, 0x2062, 0xffff);
3561 VOW12MCK_Enable(false);//VOW clock power down enable
3563 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x0180, 0x8000); //PLL low power off. BIT:15
3564 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x02F0, 0x040D); //disable fbdiv relatch (low jitter),Set DCKO = 1/4 F_PLL off, disable VOWPLL CLK. BIT:0,2,3,10
3565 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0000, 0x0003); //disable audio uplink VOW LPW globe bias, disable audio uplink LPW mode.BIT:0,1
3566 //no need to config this reg due to VOW no need
3567 //NvregEnable(true); //enable audio globe bias (Default on)
3568 Ana_Set_Reg(LDO_CON2
, 0x8102, 0x000f); //LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET, disable low power mode.BIT:0~3
3572 case AUDIO_VOW_MIC_TYPE_Handset_AMIC
:
3574 printk("%s, case AUDIO_VOW_MIC_TYPE_Handset_AMIC close\n", __func__
);
3576 // turn off digital first, move to vow driver
3577 //#ifdef VOW_STANDALONE_CONTROL
3579 //disable VOW interrupt here or when digital power off
3581 #ifdef MTK_VOW_SUPPORT
3583 //Enable VOW_CLK_MISO
3584 mt_set_gpio_mode(pin_vowclk
, GPIO_MODE_00
); //GPIO148: mode 0
3585 //Enable VOW_DAT_MISO
3586 mt_set_gpio_mode(pin_audmiso
, GPIO_MODE_01
); //GPIO25: mode 1
3589 //GPIO set to back to normal record
3590 //disable VOW_CLK_MISO
3591 mt_set_gpio_mode(GPIO_VOW_CLK_MISO_PIN
, GPIO_MODE_00
); //GPIO148: mode 0
3593 mt_set_gpio_mode(GPIO_AUD_DAT_MISO_PIN
, GPIO_MODE_01
); //GPIO25: mode 1
3597 Ana_Set_Reg(GPIO_MODE3
, 0x1249, 0xffff); //GPIO Set to VOW data
3599 VOW12MCK_Enable(false);//VOW clock power down enable
3601 //turn off analog part
3602 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0500, 0x00C1); //Audio L preamplifier input sel : off, disable audio L PGA. BIT:0,6,7
3603 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x0700); //Audio L ADC input sel : off, disable audio L ADC.BIT:8,9,10
3604 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0009, 0xf900); //PGA stb enhance off,BIT:8,15:11
3605 Ana_Set_Reg(AUDENC_ANA_CON15
, 0x0000, 0x0007); //Audio L PGA 0 dB gain,BIT:0~2
3606 Ana_Set_Reg(AUDENC_ANA_CON4
, 0x0000, 0x0800); //BIT11
3607 Ana_Set_Reg(AUDENC_ANA_CON6
, 0x2020, 0xffff);
3609 Ana_Set_Reg(AUDENC_ANA_CON9
, (MicbiasRef
|0x0000), 0x0f01); //disable MICBIAS0 lowpower mode, MISBIAS0 = 1P7V. BIT:0,8:10,11
3610 Ana_Set_Reg(AUDDEC_ANA_CON7
, 0x0000, 0x0006); //LCLDO_ENC remote sense off, BIT:1,2
3611 Ana_Set_Reg(AUDDEC_ANA_CON6
, 0x0000, 0x0100); //disable LCLDO_ENC 1P8V
3612 Ana_Set_Reg(AUDENC_ANA_CON3
, 0x0000, 0x000D); //ADC CLK from VOWPLL (12.85/4MHz) off, Enable Audio ADC FBDAC 0.25FS LPW off. BIT:0,2,3
3613 Ana_Set_Reg(AUDENC_ANA_CON13
, 0x0180, 0x8000); //PLL low power off. BIT:15
3614 Ana_Set_Reg(AUDENC_ANA_CON12
, 0x02F0, 0x040D); //disable fbdiv relatch (low jitter),Set DCKO = 1/4 F_PLL off, disable VOWPLL CLK. BIT:0,2,3,10
3615 Ana_Set_Reg(AUDENC_ANA_CON2
, 0x0000, 0x0003); //disable audio uplink VOW LPW globe bias, disable audio uplink LPW mode.BIT:0,1
3616 //Ana_Set_Reg(AUDDEC_ANA_CON8, 0x0000, 0xffff); //enable audio globe bias (Default on)
3617 //no need to config this reg due to VOW no need
3618 //NvregEnable(true); //enable audio globe bias (Default on)
3619 Ana_Set_Reg(LDO_CON2
, 0x8102, 0x000f); //LDO enable control by RG_VAUD28_EN, Enable AVDD28_LDO (Default on), LPW control by VAUD28_MODE_SET, disable low power mode.BIT:0~3
3625 SetVOWStatus(mIsVOWOn
);
3633 // here start uplink power function
3634 static const char *ADC_function
[] = {"Off", "On"};
3635 static const char *ADC_power_mode
[] = {"normal", "lowpower"};
3636 static const char *PreAmp_Mux_function
[] = {"OPEN", "IN_ADC1", "IN_ADC2", "IN_ADC3"}; //OPEN:0, IN_ADC1: 1, IN_ADC2:2, IN_ADC3:3
3637 static const char *ADC_UL_PGA_GAIN
[] = { "0Db", "6Db", "12Db", "18Db", "24Db", "30Db"};
3638 static const char *Pmic_Digital_Mux
[] = { "ADC1", "ADC2", "ADC3", "ADC4"};
3639 static const char *Adc_Input_Sel
[] = { "idle", "AIN", "Preamp"};
3640 static const char *Audio_AnalogMic_Mode
[] = { "ACCMODE", "DCCMODE", "DMIC", "DCCECMDIFFMODE", "DCCECMSINGLEMODE"};
3641 static const char *Audio_VOW_ADC_Function
[] = {"Off", "On"};
3642 static const char *Audio_VOW_Digital_Function
[] = {"Off", "On"};
3643 static const char *Audio_VOW_MIC_Type
[] = {"HandsetAMIC", "HeadsetMIC", "HandsetDMIC", "HandsetDMIC_800K", "HandsetAMIC_DCC", "HeadsetMIC_DCC", "HandsetAMIC_DCCECM", "HeadsetMIC_DCCECM"};
3646 static const struct soc_enum Audio_UL_Enum
[] =
3648 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_function
), ADC_function
),
3649 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_function
), ADC_function
),
3650 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_function
), ADC_function
),
3651 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_function
), ADC_function
),
3652 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(PreAmp_Mux_function
), PreAmp_Mux_function
),
3653 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Adc_Input_Sel
), Adc_Input_Sel
),
3654 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Adc_Input_Sel
), Adc_Input_Sel
),
3655 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Adc_Input_Sel
), Adc_Input_Sel
),
3656 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Adc_Input_Sel
), Adc_Input_Sel
),
3657 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_UL_PGA_GAIN
), ADC_UL_PGA_GAIN
),
3658 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_UL_PGA_GAIN
), ADC_UL_PGA_GAIN
),
3659 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_UL_PGA_GAIN
), ADC_UL_PGA_GAIN
),
3660 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_UL_PGA_GAIN
), ADC_UL_PGA_GAIN
),
3661 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Digital_Mux
), Pmic_Digital_Mux
),
3662 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Digital_Mux
), Pmic_Digital_Mux
),
3663 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Digital_Mux
), Pmic_Digital_Mux
),
3664 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Digital_Mux
), Pmic_Digital_Mux
),
3665 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_AnalogMic_Mode
), Audio_AnalogMic_Mode
),
3666 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_AnalogMic_Mode
), Audio_AnalogMic_Mode
),
3667 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_AnalogMic_Mode
), Audio_AnalogMic_Mode
),
3668 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_AnalogMic_Mode
), Audio_AnalogMic_Mode
),
3669 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ADC_power_mode
), ADC_power_mode
),
3670 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_VOW_ADC_Function
), Audio_VOW_ADC_Function
),
3671 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(PreAmp_Mux_function
), PreAmp_Mux_function
),
3672 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_VOW_Digital_Function
), Audio_VOW_Digital_Function
),
3673 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Audio_VOW_MIC_Type
), Audio_VOW_MIC_Type
),
3676 static int Audio_ADC1_Get(struct snd_kcontrol
*kcontrol
,
3677 struct snd_ctl_elem_value
*ucontrol
)
3679 printk("Audio_ADC1_Get = %d\n", mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC1
]);
3680 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC1
];
3684 static int Audio_ADC1_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3686 printk("%s()\n", __func__
);
3687 mutex_lock(&Ana_Power_Mutex
);
3688 if (ucontrol
->value
.integer
.value
[0])
3690 if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_ACC
)
3692 TurnOnADcPowerACC(AUDIO_ANALOG_DEVICE_IN_ADC1
, true);
3694 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCC
)
3696 TurnOnADcPowerDCC(AUDIO_ANALOG_DEVICE_IN_ADC1
, true);
3698 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DMIC
)
3700 TurnOnADcPowerDmic(AUDIO_ANALOG_DEVICE_IN_ADC1
, true);
3702 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCCECMDIFF
|| mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCCECMSINGLE
)
3704 TurnOnADcPowerDCCECM(AUDIO_ANALOG_DEVICE_IN_ADC1
, true);
3706 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC1
] = ucontrol
->value
.integer
.value
[0];
3710 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC1
] = ucontrol
->value
.integer
.value
[0];
3711 if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_ACC
)
3713 TurnOnADcPowerACC(AUDIO_ANALOG_DEVICE_IN_ADC1
, false);
3715 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCC
)
3717 TurnOnADcPowerDCC(AUDIO_ANALOG_DEVICE_IN_ADC1
, false);
3719 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DMIC
)
3721 TurnOnADcPowerDmic(AUDIO_ANALOG_DEVICE_IN_ADC1
, false);
3723 else if (mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCCECMDIFF
|| mAudio_Analog_Mic1_mode
== AUDIO_ANALOGUL_MODE_DCCECMSINGLE
)
3725 TurnOnADcPowerDCCECM(AUDIO_ANALOG_DEVICE_IN_ADC1
, false);
3728 mutex_unlock(&Ana_Power_Mutex
);
3732 static int Audio_ADC2_Get(struct snd_kcontrol
*kcontrol
,
3733 struct snd_ctl_elem_value
*ucontrol
)
3735 printk("Audio_ADC2_Get = %d\n", mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC2
]);
3736 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC2
];
3740 static int Audio_ADC2_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3742 printk("%s()\n", __func__
);
3743 mutex_lock(&Ana_Power_Mutex
);
3744 if (ucontrol
->value
.integer
.value
[0])
3746 if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_ACC
)
3748 TurnOnADcPowerACC(AUDIO_ANALOG_DEVICE_IN_ADC2
, true);
3750 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCC
)
3752 TurnOnADcPowerDCC(AUDIO_ANALOG_DEVICE_IN_ADC2
, true);
3754 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DMIC
)
3756 TurnOnADcPowerDmic(AUDIO_ANALOG_DEVICE_IN_ADC2
, true);
3758 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCCECMDIFF
|| mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCCECMSINGLE
)
3760 TurnOnADcPowerDCCECM(AUDIO_ANALOG_DEVICE_IN_ADC2
, true);
3762 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC2
] = ucontrol
->value
.integer
.value
[0];
3766 mCodec_data
->mAudio_Ana_DevicePower
[AUDIO_ANALOG_DEVICE_IN_ADC2
] = ucontrol
->value
.integer
.value
[0];
3767 if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_ACC
)
3769 TurnOnADcPowerACC(AUDIO_ANALOG_DEVICE_IN_ADC2
, false);
3771 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCC
)
3773 TurnOnADcPowerDCC(AUDIO_ANALOG_DEVICE_IN_ADC2
, false);
3775 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DMIC
)
3777 TurnOnADcPowerDmic(AUDIO_ANALOG_DEVICE_IN_ADC2
, false);
3779 else if (mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCCECMDIFF
|| mAudio_Analog_Mic2_mode
== AUDIO_ANALOGUL_MODE_DCCECMSINGLE
)
3781 TurnOnADcPowerDCCECM(AUDIO_ANALOG_DEVICE_IN_ADC2
, false);
3784 mutex_unlock(&Ana_Power_Mutex
);
3788 static int Audio_ADC3_Get(struct snd_kcontrol
*kcontrol
,
3789 struct snd_ctl_elem_value
*ucontrol
)
3795 static int Audio_ADC3_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3801 static int Audio_ADC4_Get(struct snd_kcontrol
*kcontrol
,
3802 struct snd_ctl_elem_value
*ucontrol
)
3808 static int Audio_ADC4_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3814 static int Audio_ADC1_Sel_Get(struct snd_kcontrol
*kcontrol
,
3815 struct snd_ctl_elem_value
*ucontrol
)
3817 printk("%s() = %d\n", __func__
, mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC1
]);
3818 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC1
];
3822 static int Audio_ADC1_Sel_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3824 printk("%s()\n", __func__
);
3826 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Adc_Input_Sel
))
3828 printk("return -EINVAL\n");
3831 if (ucontrol
->value
.integer
.value
[0] == 0)
3833 Ana_Set_Reg(AUDENC_ANA_CON0
, (0x0000 << 9), 0x0600); // pinumx sel
3835 else if (ucontrol
->value
.integer
.value
[0] == 1)
3837 Ana_Set_Reg(AUDENC_ANA_CON0
, (0x0001 << 9), 0x0600); //AIN0
3840 else if (ucontrol
->value
.integer
.value
[0] == 2)
3842 Ana_Set_Reg(AUDENC_ANA_CON0
, (0x0002 << 9), 0x0600); //Left preamp
3846 printk("%s() warning \n ", __func__
);
3848 printk("%s() done \n", __func__
);
3849 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC1
] = ucontrol
->value
.integer
.value
[0];
3853 static int Audio_ADC2_Sel_Get(struct snd_kcontrol
*kcontrol
,
3854 struct snd_ctl_elem_value
*ucontrol
)
3856 printk("%s() = %d\n", __func__
, mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC2
]);
3857 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC2
];
3861 static int Audio_ADC2_Sel_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3863 printk("%s()\n", __func__
);
3864 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Adc_Input_Sel
))
3866 printk("return -EINVAL\n");
3869 if (ucontrol
->value
.integer
.value
[0] == 0)
3871 Ana_Set_Reg(AUDENC_ANA_CON1
, (0x0000 << 9), 0x0600); // pinumx sel
3873 else if (ucontrol
->value
.integer
.value
[0] == 1)
3875 Ana_Set_Reg(AUDENC_ANA_CON1
, (0x0001 << 9), 0x0600); //AIN2
3877 else if (ucontrol
->value
.integer
.value
[0] == 2) //Right preamp
3879 Ana_Set_Reg(AUDENC_ANA_CON1
, (0x0002 << 9), 0x0600);
3883 printk("%s() warning \n ", __func__
);
3885 printk("%s() done \n", __func__
);
3886 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC2
] = ucontrol
->value
.integer
.value
[0];
3890 static int Audio_ADC3_Sel_Get(struct snd_kcontrol
*kcontrol
,
3891 struct snd_ctl_elem_value
*ucontrol
)
3897 static int Audio_ADC3_Sel_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3903 static int Audio_ADC4_Sel_Get(struct snd_kcontrol
*kcontrol
,
3904 struct snd_ctl_elem_value
*ucontrol
)
3910 static int Audio_ADC4_Sel_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3917 static bool AudioPreAmp1_Sel(int Mul_Sel
)
3919 printk("%s Mul_Sel = %d ", __func__
, Mul_Sel
);
3922 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0000, 0x00C0); // pinumx open
3924 else if (Mul_Sel
== 1)
3926 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0040, 0x00C0); // AIN0
3928 else if (Mul_Sel
== 2)
3930 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x0080, 0x00C0); // AIN1
3932 else if (Mul_Sel
== 3)
3934 Ana_Set_Reg(AUDENC_ANA_CON0
, 0x00C0, 0x00C0); // AIN2
3938 printk("AudioPreAmp1_Sel warning");
3944 static int Audio_PreAmp1_Get(struct snd_kcontrol
*kcontrol
,
3945 struct snd_ctl_elem_value
*ucontrol
)
3947 printk("%s() mCodec_data->mAudio_Ana_Mux[AUDIO_ANALOG_MUX_IN_PREAMP_1]; = %d\n", __func__
, mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_1
]);
3948 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_1
];
3952 static int Audio_PreAmp1_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3954 printk("%s()\n", __func__
);
3956 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(PreAmp_Mux_function
))
3958 printk("return -EINVAL\n");
3961 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_1
] = ucontrol
->value
.integer
.value
[0];
3962 AudioPreAmp1_Sel(mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_1
]);
3963 printk("%s() done \n", __func__
);
3967 static bool AudioPreAmp2_Sel(int Mul_Sel
)
3969 printk("%s Mul_Sel = %d ", __func__
, Mul_Sel
);
3972 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0000, 0x00C0); // pinumx open
3974 else if (Mul_Sel
== 1)
3976 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x00C0, 0x00C0); // AIN2
3978 else if (Mul_Sel
== 2)
3980 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0080, 0x00C0); // AIN1
3982 else if (Mul_Sel
== 3)
3984 Ana_Set_Reg(AUDENC_ANA_CON1
, 0x0040, 0x00C0); // AIN0
3988 printk("AudioPreAmp1_Sel warning");
3994 static int Audio_PreAmp2_Get(struct snd_kcontrol
*kcontrol
,
3995 struct snd_ctl_elem_value
*ucontrol
)
3997 printk("%s() mCodec_data->mAudio_Ana_Mux[AUDIO_ANALOG_MUX_IN_PREAMP_2]; = %d\n", __func__
, mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_2
]);
3998 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_2
];
4002 static int Audio_PreAmp2_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4004 printk("%s()\n", __func__
);
4006 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(PreAmp_Mux_function
))
4008 printk("return -EINVAL\n");
4011 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_2
] = ucontrol
->value
.integer
.value
[0];
4012 AudioPreAmp2_Sel(mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_PREAMP_2
]);
4013 printk("%s() done \n", __func__
);
4018 static int Audio_PGA1_Get(struct snd_kcontrol
*kcontrol
,
4019 struct snd_ctl_elem_value
*ucontrol
)
4021 printk("Audio_AmpR_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP1
]);
4022 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP1
];
4026 static int Audio_PGA1_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4029 printk("%s()\n", __func__
);
4030 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(ADC_UL_PGA_GAIN
))
4032 printk("return -EINVAL\n");
4035 index
= ucontrol
->value
.integer
.value
[0];
4036 Ana_Set_Reg(AUDENC_ANA_CON15
, index
, 0x0007);
4037 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP1
] = ucontrol
->value
.integer
.value
[0];
4042 static int Audio_PGA2_Get(struct snd_kcontrol
*kcontrol
,
4043 struct snd_ctl_elem_value
*ucontrol
)
4045 printk("Audio_PGA2_Get = %d\n", mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP2
]);
4046 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP2
];
4050 static int Audio_PGA2_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4053 printk("%s()\n", __func__
);
4054 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(ADC_UL_PGA_GAIN
))
4056 printk("return -EINVAL\n");
4059 index
= ucontrol
->value
.integer
.value
[0];
4060 Ana_Set_Reg(AUDENC_ANA_CON15
, index
<< 4, 0x0070);
4061 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP2
] = ucontrol
->value
.integer
.value
[0];
4065 static int Audio_PGA3_Get(struct snd_kcontrol
*kcontrol
,
4066 struct snd_ctl_elem_value
*ucontrol
)
4072 static int Audio_PGA3_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4078 static int Audio_PGA4_Get(struct snd_kcontrol
*kcontrol
,
4079 struct snd_ctl_elem_value
*ucontrol
)
4085 static int Audio_PGA4_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4091 static int Audio_MicSource1_Get(struct snd_kcontrol
*kcontrol
,
4092 struct snd_ctl_elem_value
*ucontrol
)
4094 printk("Audio_MicSource1_Get = %d\n", mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
]);
4095 ucontrol
->value
.integer
.value
[0] = mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
];
4099 static int Audio_MicSource1_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4101 //K2 used for ADC1 Mic source selection, "ADC1" is main_mic, "ADC2" is headset_mic
4103 printk("%s()\n", __func__
);
4104 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Pmic_Digital_Mux
))
4106 printk("return -EINVAL\n");
4109 index
= ucontrol
->value
.integer
.value
[0];
4110 printk("%s() index = %d done \n", __func__
, index
);
4111 mCodec_data
->mAudio_Ana_Mux
[AUDIO_MICSOURCE_MUX_IN_1
] = ucontrol
->value
.integer
.value
[0];
4116 static int Audio_MicSource2_Get(struct snd_kcontrol
*kcontrol
,
4117 struct snd_ctl_elem_value
*ucontrol
)
4123 static int Audio_MicSource2_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4129 static int Audio_MicSource3_Get(struct snd_kcontrol
*kcontrol
,
4130 struct snd_ctl_elem_value
*ucontrol
)
4136 static int Audio_MicSource3_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4143 static int Audio_MicSource4_Get(struct snd_kcontrol
*kcontrol
,
4144 struct snd_ctl_elem_value
*ucontrol
)
4150 static int Audio_MicSource4_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4156 // Mic ACC/DCC Mode Setting
4157 static int Audio_Mic1_Mode_Select_Get(struct snd_kcontrol
*kcontrol
,
4158 struct snd_ctl_elem_value
*ucontrol
)
4160 printk("%s() mAudio_Analog_Mic1_mode = %d\n", __func__
, mAudio_Analog_Mic1_mode
);
4161 ucontrol
->value
.integer
.value
[0] = mAudio_Analog_Mic1_mode
;
4165 static int Audio_Mic1_Mode_Select_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4167 printk("%s()\n", __func__
);
4168 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_AnalogMic_Mode
))
4170 printk("return -EINVAL\n");
4173 mAudio_Analog_Mic1_mode
= ucontrol
->value
.integer
.value
[0];
4174 printk("%s() mAudio_Analog_Mic1_mode = %d \n", __func__
, mAudio_Analog_Mic1_mode
);
4178 static int Audio_Mic2_Mode_Select_Get(struct snd_kcontrol
*kcontrol
,
4179 struct snd_ctl_elem_value
*ucontrol
)
4181 printk("%s() = %d\n", __func__
, mAudio_Analog_Mic2_mode
);
4182 ucontrol
->value
.integer
.value
[0] = mAudio_Analog_Mic2_mode
;
4186 static int Audio_Mic2_Mode_Select_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4188 printk("%s()\n", __func__
);
4189 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_AnalogMic_Mode
))
4191 printk("return -EINVAL\n");
4194 mAudio_Analog_Mic2_mode
= ucontrol
->value
.integer
.value
[0];
4195 printk("%s() mAudio_Analog_Mic2_mode = %d \n", __func__
, mAudio_Analog_Mic2_mode
);
4200 static int Audio_Mic3_Mode_Select_Get(struct snd_kcontrol
*kcontrol
,
4201 struct snd_ctl_elem_value
*ucontrol
)
4203 printk("%s() = %d\n", __func__
, mAudio_Analog_Mic3_mode
);
4204 ucontrol
->value
.integer
.value
[0] = mAudio_Analog_Mic3_mode
;
4208 static int Audio_Mic3_Mode_Select_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4210 printk("%s()\n", __func__
);
4211 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_AnalogMic_Mode
))
4213 printk("return -EINVAL\n");
4216 mAudio_Analog_Mic3_mode
= ucontrol
->value
.integer
.value
[0];
4217 printk("%s() mAudio_Analog_Mic3_mode = %d \n", __func__
, mAudio_Analog_Mic3_mode
);
4221 static int Audio_Mic4_Mode_Select_Get(struct snd_kcontrol
*kcontrol
,
4222 struct snd_ctl_elem_value
*ucontrol
)
4224 printk("%s() = %d\n", __func__
, mAudio_Analog_Mic4_mode
);
4225 ucontrol
->value
.integer
.value
[0] = mAudio_Analog_Mic4_mode
;
4229 static int Audio_Mic4_Mode_Select_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4231 printk("%s()\n", __func__
);
4232 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_AnalogMic_Mode
))
4234 printk("return -EINVAL\n");
4237 mAudio_Analog_Mic4_mode
= ucontrol
->value
.integer
.value
[0];
4238 printk("%s() mAudio_Analog_Mic4_mode = %d \n", __func__
, mAudio_Analog_Mic4_mode
);
4242 static int Audio_Adc_Power_Mode_Get(struct snd_kcontrol
*kcontrol
,
4243 struct snd_ctl_elem_value
*ucontrol
)
4245 printk("%s() = %d\n", __func__
, mAdc_Power_Mode
);
4246 ucontrol
->value
.integer
.value
[0] = mAdc_Power_Mode
;
4250 static int Audio_Adc_Power_Mode_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4252 printk("%s()\n", __func__
);
4253 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(ADC_power_mode
))
4255 printk("return -EINVAL\n");
4258 mAdc_Power_Mode
= ucontrol
->value
.integer
.value
[0];
4259 printk("%s() mAdc_Power_Mode = %d \n", __func__
, mAdc_Power_Mode
);
4264 static int Audio_Vow_ADC_Func_Switch_Get(struct snd_kcontrol
*kcontrol
,
4265 struct snd_ctl_elem_value
*ucontrol
)
4267 printk("%s() = %d\n", __func__
, mAudio_Vow_Analog_Func_Enable
);
4268 ucontrol
->value
.integer
.value
[0] = mAudio_Vow_Analog_Func_Enable
;
4272 static int Audio_Vow_ADC_Func_Switch_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4274 printk("%s()\n", __func__
);
4275 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_VOW_ADC_Function
))
4277 printk("return -EINVAL\n");
4281 if (ucontrol
->value
.integer
.value
[0])
4283 TurnOnVOWADcPowerACC(mAudio_VOW_Mic_type
, true);
4287 TurnOnVOWADcPowerACC(mAudio_VOW_Mic_type
, false);
4290 mAudio_Vow_Analog_Func_Enable
= ucontrol
->value
.integer
.value
[0];
4291 printk("%s() mAudio_Vow_Analog_Func_Enable = %d \n", __func__
, mAudio_Vow_Analog_Func_Enable
);
4295 static int Audio_Vow_Digital_Func_Switch_Get(struct snd_kcontrol
*kcontrol
,
4296 struct snd_ctl_elem_value
*ucontrol
)
4298 printk("%s() = %d\n", __func__
, mAudio_Vow_Digital_Func_Enable
);
4299 ucontrol
->value
.integer
.value
[0] = mAudio_Vow_Digital_Func_Enable
;
4303 static int Audio_Vow_Digital_Func_Switch_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4305 printk("%s()\n", __func__
);
4306 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_VOW_Digital_Function
))
4308 printk("return -EINVAL\n");
4312 if (ucontrol
->value
.integer
.value
[0])
4314 TurnOnVOWDigitalHW(true);
4318 TurnOnVOWDigitalHW(false);
4321 mAudio_Vow_Digital_Func_Enable
= ucontrol
->value
.integer
.value
[0];
4322 printk("%s() mAudio_Vow_Digital_Func_Enable = %d \n", __func__
, mAudio_Vow_Digital_Func_Enable
);
4327 static int Audio_Vow_MIC_Type_Select_Get(struct snd_kcontrol
*kcontrol
,
4328 struct snd_ctl_elem_value
*ucontrol
)
4330 printk("%s() = %d\n", __func__
, mAudio_VOW_Mic_type
);
4331 ucontrol
->value
.integer
.value
[0] = mAudio_VOW_Mic_type
;
4335 static int Audio_Vow_MIC_Type_Select_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4337 printk("%s()\n", __func__
);
4338 if (ucontrol
->value
.enumerated
.item
[0] > ARRAY_SIZE(Audio_VOW_MIC_Type
))
4340 printk("return -EINVAL\n");
4343 mAudio_VOW_Mic_type
= ucontrol
->value
.integer
.value
[0];
4344 printk("%s() mAudio_VOW_Mic_type = %d \n", __func__
, mAudio_VOW_Mic_type
);
4349 static int Audio_Vow_Cfg0_Get(struct snd_kcontrol
*kcontrol
,
4350 struct snd_ctl_elem_value
*ucontrol
)
4352 int value
= /*Ana_Get_Reg(AFE_VOW_CFG0)*/reg_AFE_VOW_CFG0
;
4353 printk("%s() = %d\n", __func__
, value
);
4354 ucontrol
->value
.integer
.value
[0] = value
;
4358 static int Audio_Vow_Cfg0_Set(struct snd_kcontrol
*kcontrol
,
4359 struct snd_ctl_elem_value
*ucontrol
)
4361 printk("%s() = %d\n", __func__
, (int)(ucontrol
->value
.integer
.value
[0]));
4362 //Ana_Set_Reg(AFE_VOW_CFG0, ucontrol->value.integer.value[0], 0xffff);
4363 reg_AFE_VOW_CFG0
= ucontrol
->value
.integer
.value
[0];
4367 static int Audio_Vow_Cfg1_Get(struct snd_kcontrol
*kcontrol
,
4368 struct snd_ctl_elem_value
*ucontrol
)
4370 int value
= /*Ana_Get_Reg(AFE_VOW_CFG1)*/reg_AFE_VOW_CFG1
;
4371 printk("%s() = %d\n", __func__
, value
);
4372 ucontrol
->value
.integer
.value
[0] = value
;
4376 static int Audio_Vow_Cfg1_Set(struct snd_kcontrol
*kcontrol
,
4377 struct snd_ctl_elem_value
*ucontrol
)
4379 printk("%s() = %ld\n", __func__
, ucontrol
->value
.integer
.value
[0]);
4380 //Ana_Set_Reg(AFE_VOW_CFG1, ucontrol->value.integer.value[0], 0xffff);
4381 reg_AFE_VOW_CFG1
= ucontrol
->value
.integer
.value
[0];
4385 static int Audio_Vow_Cfg2_Get(struct snd_kcontrol
*kcontrol
,
4386 struct snd_ctl_elem_value
*ucontrol
)
4388 int value
= /*Ana_Get_Reg(AFE_VOW_CFG2)*/reg_AFE_VOW_CFG2
;
4389 printk("%s() = %d\n", __func__
, value
);
4390 ucontrol
->value
.integer
.value
[0] = value
;
4394 static int Audio_Vow_Cfg2_Set(struct snd_kcontrol
*kcontrol
,
4395 struct snd_ctl_elem_value
*ucontrol
)
4397 printk("%s() = %ld\n", __func__
, ucontrol
->value
.integer
.value
[0]);
4398 //Ana_Set_Reg(AFE_VOW_CFG2, ucontrol->value.integer.value[0], 0xffff);
4399 reg_AFE_VOW_CFG2
= ucontrol
->value
.integer
.value
[0];
4403 static int Audio_Vow_Cfg3_Get(struct snd_kcontrol
*kcontrol
,
4404 struct snd_ctl_elem_value
*ucontrol
)
4406 int value
= /*Ana_Get_Reg(AFE_VOW_CFG3)*/reg_AFE_VOW_CFG3
;
4407 printk("%s() = %d\n", __func__
, value
);
4408 ucontrol
->value
.integer
.value
[0] = value
;
4412 static int Audio_Vow_Cfg3_Set(struct snd_kcontrol
*kcontrol
,
4413 struct snd_ctl_elem_value
*ucontrol
)
4415 printk("%s() = %ld\n", __func__
, ucontrol
->value
.integer
.value
[0]);
4416 //Ana_Set_Reg(AFE_VOW_CFG3, ucontrol->value.integer.value[0], 0xffff);
4417 reg_AFE_VOW_CFG3
= ucontrol
->value
.integer
.value
[0];
4421 static int Audio_Vow_Cfg4_Get(struct snd_kcontrol
*kcontrol
,
4422 struct snd_ctl_elem_value
*ucontrol
)
4424 int value
= /*Ana_Get_Reg(AFE_VOW_CFG4)*/reg_AFE_VOW_CFG4
;
4425 printk("%s() = %d\n", __func__
, value
);
4426 ucontrol
->value
.integer
.value
[0] = value
;
4430 static int Audio_Vow_Cfg4_Set(struct snd_kcontrol
*kcontrol
,
4431 struct snd_ctl_elem_value
*ucontrol
)
4433 printk("%s() = %ld\n", __func__
, ucontrol
->value
.integer
.value
[0]);
4434 //Ana_Set_Reg(AFE_VOW_CFG4, ucontrol->value.integer.value[0], 0xffff);
4435 reg_AFE_VOW_CFG4
= ucontrol
->value
.integer
.value
[0];
4439 static int Audio_Vow_Cfg5_Get(struct snd_kcontrol
*kcontrol
,
4440 struct snd_ctl_elem_value
*ucontrol
)
4442 int value
= /*Ana_Get_Reg(AFE_VOW_CFG5)*/reg_AFE_VOW_CFG5
;
4443 printk("%s() = %d\n", __func__
, value
);
4444 ucontrol
->value
.integer
.value
[0] = value
;
4448 static int Audio_Vow_Cfg5_Set(struct snd_kcontrol
*kcontrol
,
4449 struct snd_ctl_elem_value
*ucontrol
)
4451 printk("%s() = %ld\n", __func__
, ucontrol
->value
.integer
.value
[0]);
4452 //Ana_Set_Reg(AFE_VOW_CFG5, ucontrol->value.integer.value[0], 0xffff);
4453 reg_AFE_VOW_CFG5
= ucontrol
->value
.integer
.value
[0];
4457 static int Audio_Vow_State_Get(struct snd_kcontrol
*kcontrol
,
4458 struct snd_ctl_elem_value
*ucontrol
)
4460 int value
= mIsVOWOn
;
4461 printk("%s() = %d\n", __func__
, value
);
4462 ucontrol
->value
.integer
.value
[0] = value
;
4466 static int Audio_Vow_State_Set(struct snd_kcontrol
*kcontrol
,
4467 struct snd_ctl_elem_value
*ucontrol
)
4469 //printk("%s() = %ld\n", __func__, ucontrol->value.integer.value[0]);
4470 //reg_AFE_VOW_CFG5 = ucontrol->value.integer.value[0];
4474 static bool SineTable_DAC_HP_flag
= false;
4475 static bool SineTable_UL2_flag
= false;
4477 static int SineTable_UL2_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4479 if (ucontrol
->value
.integer
.value
[0])
4481 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, 0x0002 , 0x2); //set DL sine gen table
4482 Ana_Set_Reg(AFE_SGEN_CFG0
, 0x0080 , 0xffff);
4483 Ana_Set_Reg(AFE_SGEN_CFG1
, 0x0101 , 0xffff);
4487 Ana_Set_Reg(PMIC_AFE_TOP_CON0
, 0x0002 , 0x2); //set DL sine gen table
4488 Ana_Set_Reg(AFE_SGEN_CFG0
, 0x0000 , 0xffff);
4489 Ana_Set_Reg(AFE_SGEN_CFG1
, 0x0101 , 0xffff);
4494 static int SineTable_UL2_Get(struct snd_kcontrol
*kcontrol
,
4495 struct snd_ctl_elem_value
*ucontrol
)
4497 printk("%s()\n", __func__
);
4498 ucontrol
->value
.integer
.value
[0] = SineTable_UL2_flag
;
4502 static int SineTable_DAC_HP_Get(struct snd_kcontrol
*kcontrol
,
4503 struct snd_ctl_elem_value
*ucontrol
)
4505 printk("%s()\n", __func__
);
4506 ucontrol
->value
.integer
.value
[0] = SineTable_DAC_HP_flag
;
4510 static int SineTable_DAC_HP_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4513 printk("%s()\n", __func__
);
4517 static void ADC_LOOP_DAC_Func(int command
)
4522 static bool DAC_LOOP_DAC_HS_flag
= false;
4523 static int ADC_LOOP_DAC_HS_Get(struct snd_kcontrol
*kcontrol
,
4524 struct snd_ctl_elem_value
*ucontrol
)
4526 printk("%s()\n", __func__
);
4527 ucontrol
->value
.integer
.value
[0] = DAC_LOOP_DAC_HS_flag
;
4531 static int ADC_LOOP_DAC_HS_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4533 printk("%s()\n", __func__
);
4534 if (ucontrol
->value
.integer
.value
[0])
4536 DAC_LOOP_DAC_HS_flag
= ucontrol
->value
.integer
.value
[0];
4537 ADC_LOOP_DAC_Func(AUDIO_ANALOG_DAC_LOOP_DAC_HS_ON
);
4541 DAC_LOOP_DAC_HS_flag
= ucontrol
->value
.integer
.value
[0];
4542 ADC_LOOP_DAC_Func(AUDIO_ANALOG_DAC_LOOP_DAC_HS_OFF
);
4547 static bool DAC_LOOP_DAC_HP_flag
= false;
4548 static int ADC_LOOP_DAC_HP_Get(struct snd_kcontrol
*kcontrol
,
4549 struct snd_ctl_elem_value
*ucontrol
)
4551 printk("%s()\n", __func__
);
4552 ucontrol
->value
.integer
.value
[0] = DAC_LOOP_DAC_HP_flag
;
4556 static int ADC_LOOP_DAC_HP_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4559 printk("%s()\n", __func__
);
4560 if (ucontrol
->value
.integer
.value
[0])
4562 DAC_LOOP_DAC_HP_flag
= ucontrol
->value
.integer
.value
[0];
4563 ADC_LOOP_DAC_Func(AUDIO_ANALOG_DAC_LOOP_DAC_HP_ON
);
4567 DAC_LOOP_DAC_HP_flag
= ucontrol
->value
.integer
.value
[0];
4568 ADC_LOOP_DAC_Func(AUDIO_ANALOG_DAC_LOOP_DAC_HP_OFF
);
4573 static bool Voice_Call_DAC_DAC_HS_flag
= false;
4574 static int Voice_Call_DAC_DAC_HS_Get(struct snd_kcontrol
*kcontrol
,
4575 struct snd_ctl_elem_value
*ucontrol
)
4577 printk("%s()\n", __func__
);
4578 ucontrol
->value
.integer
.value
[0] = Voice_Call_DAC_DAC_HS_flag
;
4582 static int Voice_Call_DAC_DAC_HS_Set(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
4585 printk("%s()\n", __func__
);
4589 // here start uplink power function
4590 static const char *Pmic_Test_function
[] = {"Off", "On"};
4592 static const struct soc_enum Pmic_Test_Enum
[] =
4594 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Test_function
), Pmic_Test_function
),
4595 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Test_function
), Pmic_Test_function
),
4596 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Test_function
), Pmic_Test_function
),
4597 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Test_function
), Pmic_Test_function
),
4598 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(Pmic_Test_function
), Pmic_Test_function
),
4601 static const struct snd_kcontrol_new mt6331_pmic_Test_controls
[] =
4603 SOC_ENUM_EXT("SineTable_DAC_HP", Pmic_Test_Enum
[0], SineTable_DAC_HP_Get
, SineTable_DAC_HP_Set
),
4604 SOC_ENUM_EXT("DAC_LOOP_DAC_HS", Pmic_Test_Enum
[1], ADC_LOOP_DAC_HS_Get
, ADC_LOOP_DAC_HS_Set
),
4605 SOC_ENUM_EXT("DAC_LOOP_DAC_HP", Pmic_Test_Enum
[2], ADC_LOOP_DAC_HP_Get
, ADC_LOOP_DAC_HP_Set
),
4606 SOC_ENUM_EXT("Voice_Call_DAC_DAC_HS", Pmic_Test_Enum
[3], Voice_Call_DAC_DAC_HS_Get
, Voice_Call_DAC_DAC_HS_Set
),
4607 SOC_ENUM_EXT("SineTable_UL2", Pmic_Test_Enum
[4], SineTable_UL2_Get
, SineTable_UL2_Set
),
4610 static const struct snd_kcontrol_new mt6331_UL_Codec_controls
[] =
4612 SOC_ENUM_EXT("Audio_ADC_1_Switch", Audio_UL_Enum
[0], Audio_ADC1_Get
, Audio_ADC1_Set
),
4613 SOC_ENUM_EXT("Audio_ADC_2_Switch", Audio_UL_Enum
[1], Audio_ADC2_Get
, Audio_ADC2_Set
),
4614 SOC_ENUM_EXT("Audio_ADC_3_Switch", Audio_UL_Enum
[2], Audio_ADC3_Get
, Audio_ADC3_Set
),
4615 SOC_ENUM_EXT("Audio_ADC_4_Switch", Audio_UL_Enum
[3], Audio_ADC4_Get
, Audio_ADC4_Set
),
4616 SOC_ENUM_EXT("Audio_Preamp1_Switch", Audio_UL_Enum
[4], Audio_PreAmp1_Get
, Audio_PreAmp1_Set
),
4617 SOC_ENUM_EXT("Audio_ADC_1_Sel", Audio_UL_Enum
[5], Audio_ADC1_Sel_Get
, Audio_ADC1_Sel_Set
),
4618 SOC_ENUM_EXT("Audio_ADC_2_Sel", Audio_UL_Enum
[6], Audio_ADC2_Sel_Get
, Audio_ADC2_Sel_Set
),
4619 SOC_ENUM_EXT("Audio_ADC_3_Sel", Audio_UL_Enum
[7], Audio_ADC3_Sel_Get
, Audio_ADC3_Sel_Set
),
4620 SOC_ENUM_EXT("Audio_ADC_4_Sel", Audio_UL_Enum
[8], Audio_ADC4_Sel_Get
, Audio_ADC4_Sel_Set
),
4621 SOC_ENUM_EXT("Audio_PGA1_Setting", Audio_UL_Enum
[9], Audio_PGA1_Get
, Audio_PGA1_Set
),
4622 SOC_ENUM_EXT("Audio_PGA2_Setting", Audio_UL_Enum
[10], Audio_PGA2_Get
, Audio_PGA2_Set
),
4623 SOC_ENUM_EXT("Audio_PGA3_Setting", Audio_UL_Enum
[11], Audio_PGA3_Get
, Audio_PGA3_Set
),
4624 SOC_ENUM_EXT("Audio_PGA4_Setting", Audio_UL_Enum
[12], Audio_PGA4_Get
, Audio_PGA4_Set
),
4625 SOC_ENUM_EXT("Audio_MicSource1_Setting", Audio_UL_Enum
[13], Audio_MicSource1_Get
, Audio_MicSource1_Set
),
4626 SOC_ENUM_EXT("Audio_MicSource2_Setting", Audio_UL_Enum
[14], Audio_MicSource2_Get
, Audio_MicSource2_Set
),
4627 SOC_ENUM_EXT("Audio_MicSource3_Setting", Audio_UL_Enum
[15], Audio_MicSource3_Get
, Audio_MicSource3_Set
),
4628 SOC_ENUM_EXT("Audio_MicSource4_Setting", Audio_UL_Enum
[16], Audio_MicSource4_Get
, Audio_MicSource4_Set
),
4629 SOC_ENUM_EXT("Audio_MIC1_Mode_Select", Audio_UL_Enum
[17], Audio_Mic1_Mode_Select_Get
, Audio_Mic1_Mode_Select_Set
),
4630 SOC_ENUM_EXT("Audio_MIC2_Mode_Select", Audio_UL_Enum
[18], Audio_Mic2_Mode_Select_Get
, Audio_Mic2_Mode_Select_Set
),
4631 SOC_ENUM_EXT("Audio_MIC3_Mode_Select", Audio_UL_Enum
[19], Audio_Mic3_Mode_Select_Get
, Audio_Mic3_Mode_Select_Set
),
4632 SOC_ENUM_EXT("Audio_MIC4_Mode_Select", Audio_UL_Enum
[20], Audio_Mic4_Mode_Select_Get
, Audio_Mic4_Mode_Select_Set
),
4633 SOC_ENUM_EXT("Audio_Mic_Power_Mode", Audio_UL_Enum
[21], Audio_Adc_Power_Mode_Get
, Audio_Adc_Power_Mode_Set
),
4634 SOC_ENUM_EXT("Audio_Vow_ADC_Func_Switch", Audio_UL_Enum
[22], Audio_Vow_ADC_Func_Switch_Get
, Audio_Vow_ADC_Func_Switch_Set
),
4635 SOC_ENUM_EXT("Audio_Preamp2_Switch", Audio_UL_Enum
[23], Audio_PreAmp2_Get
, Audio_PreAmp2_Set
),
4636 SOC_ENUM_EXT("Audio_Vow_Digital_Func_Switch", Audio_UL_Enum
[24], Audio_Vow_Digital_Func_Switch_Get
, Audio_Vow_Digital_Func_Switch_Set
),
4637 SOC_ENUM_EXT("Audio_Vow_MIC_Type_Select", Audio_UL_Enum
[25], Audio_Vow_MIC_Type_Select_Get
, Audio_Vow_MIC_Type_Select_Set
),
4638 SOC_SINGLE_EXT("Audio VOWCFG0 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg0_Get
, Audio_Vow_Cfg0_Set
),
4639 SOC_SINGLE_EXT("Audio VOWCFG1 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg1_Get
, Audio_Vow_Cfg1_Set
),
4640 SOC_SINGLE_EXT("Audio VOWCFG2 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg2_Get
, Audio_Vow_Cfg2_Set
),
4641 SOC_SINGLE_EXT("Audio VOWCFG3 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg3_Get
, Audio_Vow_Cfg3_Set
),
4642 SOC_SINGLE_EXT("Audio VOWCFG4 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg4_Get
, Audio_Vow_Cfg4_Set
),
4643 SOC_SINGLE_EXT("Audio VOWCFG5 Data", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_Cfg5_Get
, Audio_Vow_Cfg5_Set
),
4644 SOC_SINGLE_EXT("Audio_VOW_State", SND_SOC_NOPM
, 0, 0x80000, 0, Audio_Vow_State_Get
, Audio_Vow_State_Set
),
4647 static const struct snd_soc_dapm_widget mt6331_dapm_widgets
[] =
4650 SND_SOC_DAPM_OUTPUT("EARPIECE"),
4651 SND_SOC_DAPM_OUTPUT("HEADSET"),
4652 SND_SOC_DAPM_OUTPUT("SPEAKER"),
4654 SND_SOC_DAPM_MUX_E("VOICE_Mux_E", SND_SOC_NOPM, 0, 0 , &mt6331_Voice_Switch, codec_enable_rx_bias,
4655 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
4656 SND_SOC_DAPM_PRE_REG | SND_SOC_DAPM_POST_REG),
4661 static const struct snd_soc_dapm_route mtk_audio_map
[] =
4663 {"VOICE_Mux_E", "Voice Mux", "SPEAKER PGA"},
4666 static void mt6331_codec_init_reg(struct snd_soc_codec
*codec
)
4668 printk("%s \n", __func__
);
4669 Ana_Set_Reg(TOP_CLKSQ
, 0x0 , 0x0001); //Disable CLKSQ 26MHz
4670 Ana_Set_Reg(AUDDEC_ANA_CON8
, 0x0002, 0x0002); // disable AUDGLB
4671 Ana_Set_Reg(TOP_CKPDN_CON0_SET
, 0x3800, 0x3800); //Turn off AUDNCP_CLKDIV engine clock,Turn off AUD 26M
4672 Ana_Set_Reg(AUDDEC_ANA_CON0
, 0xe000 , 0xe000); //Disable HeadphoneL/HeadphoneR/voice short circuit protection
4675 void InitCodecDefault(void)
4677 printk("%s\n", __func__
);
4678 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP1
] = 3;
4679 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP2
] = 3;
4680 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP3
] = 3;
4681 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_MICAMP4
] = 3;
4682 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
] = 8;
4683 mCodec_data
->mAudio_Ana_Volume
[AUDIO_ANALOG_VOLUME_HPOUTR
] = 8;
4685 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC1
] = AUDIO_ANALOG_AUDIOANALOG_INPUT_PREAMP
;
4686 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC2
] = AUDIO_ANALOG_AUDIOANALOG_INPUT_PREAMP
;
4687 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC3
] = AUDIO_ANALOG_AUDIOANALOG_INPUT_PREAMP
;
4688 mCodec_data
->mAudio_Ana_Mux
[AUDIO_ANALOG_MUX_IN_MIC4
] = AUDIO_ANALOG_AUDIOANALOG_INPUT_PREAMP
;
4691 static int mt6331_codec_probe(struct snd_soc_codec
*codec
)
4693 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
4694 printk("%s()\n", __func__
);
4695 if (mInitCodec
== true)
4700 snd_soc_dapm_new_controls(dapm
, mt6331_dapm_widgets
,
4701 ARRAY_SIZE(mt6331_dapm_widgets
));
4702 snd_soc_dapm_add_routes(dapm
, mtk_audio_map
,
4703 ARRAY_SIZE(mtk_audio_map
));
4705 //add codec controls
4706 snd_soc_add_codec_controls(codec
, mt6331_snd_controls
,
4707 ARRAY_SIZE(mt6331_snd_controls
));
4708 snd_soc_add_codec_controls(codec
, mt6331_UL_Codec_controls
,
4709 ARRAY_SIZE(mt6331_UL_Codec_controls
));
4710 snd_soc_add_codec_controls(codec
, mt6331_Voice_Switch
,
4711 ARRAY_SIZE(mt6331_Voice_Switch
));
4712 snd_soc_add_codec_controls(codec
, mt6331_pmic_Test_controls
,
4713 ARRAY_SIZE(mt6331_pmic_Test_controls
));
4715 #ifdef CONFIG_MTK_SPEAKER
4716 snd_soc_add_codec_controls(codec
, mt6331_snd_Speaker_controls
,
4717 ARRAY_SIZE(mt6331_snd_Speaker_controls
));
4720 snd_soc_add_codec_controls(codec
, Audio_snd_auxadc_controls
,
4721 ARRAY_SIZE(Audio_snd_auxadc_controls
));
4723 // here to set private data
4724 mCodec_data
= kzalloc(sizeof(mt6331_Codec_Data_Priv
), GFP_KERNEL
);
4727 printk("Failed to allocate private data\n");
4730 snd_soc_codec_set_drvdata(codec
, mCodec_data
);
4732 memset((void *)mCodec_data
, 0 , sizeof(mt6331_Codec_Data_Priv
));
4733 mt6331_codec_init_reg(codec
);
4740 static int mt6331_codec_remove(struct snd_soc_codec
*codec
)
4742 printk("%s()\n", __func__
);
4746 static unsigned int mt6331_read(struct snd_soc_codec
*codec
,
4749 printk("mt6331_read reg = 0x%x", reg
);
4754 static int mt6331_write(struct snd_soc_codec
*codec
, unsigned int reg
,
4757 printk("mt6331_write reg = 0x%x value= 0x%x\n", reg
, value
);
4758 Ana_Set_Reg(reg
, value
, 0xffffffff);
4762 static int mt6331_Readable_registers(struct snd_soc_codec
*codec
,
4768 static int mt6331_volatile_registers(struct snd_soc_codec
*codec
,
4774 static struct snd_soc_codec_driver soc_mtk_codec
=
4776 .probe
= mt6331_codec_probe
,
4777 .remove
= mt6331_codec_remove
,
4779 .read
= mt6331_read
,
4780 .write
= mt6331_write
,
4782 .readable_register
= mt6331_Readable_registers
,
4783 .volatile_register
= mt6331_volatile_registers
,
4785 // use add control to replace
4786 //.controls = mt6331_snd_controls,
4787 //.num_controls = ARRAY_SIZE(mt6331_snd_controls),
4789 .dapm_widgets
= mt6331_dapm_widgets
,
4790 .num_dapm_widgets
= ARRAY_SIZE(mt6331_dapm_widgets
),
4791 .dapm_routes
= mtk_audio_map
,
4792 .num_dapm_routes
= ARRAY_SIZE(mtk_audio_map
),
4796 static int mtk_mt6331_codec_dev_probe(struct platform_device
*pdev
)
4798 pdev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(64);
4799 if (pdev
->dev
.dma_mask
== NULL
)
4801 pdev
->dev
.dma_mask
= &pdev
->dev
.coherent_dma_mask
;
4804 if (pdev
->dev
.of_node
)
4806 dev_set_name(&pdev
->dev
, "%s", MT_SOC_CODEC_NAME
);
4809 printk("%s: dev name %s\n", __func__
, dev_name(&pdev
->dev
));
4810 return snd_soc_register_codec(&pdev
->dev
,
4811 &soc_mtk_codec
, mtk_6331_dai_codecs
, ARRAY_SIZE(mtk_6331_dai_codecs
));
4814 static int mtk_mt6331_codec_dev_remove(struct platform_device
*pdev
)
4816 printk("%s:\n", __func__
);
4818 snd_soc_unregister_codec(&pdev
->dev
);
4824 static const struct of_device_id mt_soc_codec_63xx_of_ids
[] =
4826 { .compatible
= "mediatek,mt_soc_codec_63xx", },
4831 static int Auddrv_getGPIO_info(void)
4833 struct device_node
*node
= NULL
;
4835 node
= of_find_compatible_node(NULL
, NULL
, "mediatek,mt_soc_codec_63xx");
4838 if (of_property_read_u32_index(node
, "extspkamp-gpio", 0, &pin_extspkamp
))
4841 printk("extspkamp-gpio get pin fail!!!\n");
4844 if (of_property_read_u32_index(node
, "extspkamp-gpio", 1, &pin_mode_extspkamp
))
4847 printk("extspkamp-gpio get pin_mode fail!!!\n");
4851 if (of_property_read_u32_index(node
, "vowclk-gpio", 0, &pin_vowclk
))
4854 printk("vowclk-gpio get pin fail!!!\n");
4857 if (of_property_read_u32_index(node
, "vowclk-gpio", 1, &pin_mode_vowclk
))
4860 printk("vowclk-gpio get pin_mode fail!!!\n");
4864 if (of_property_read_u32_index(node
, "audmiso-gpio", 0, &pin_audmiso
))
4867 printk("audmiso-gpio get pin fail!!!\n");
4870 if (of_property_read_u32_index(node
, "audmiso-gpio", 1, &pin_mode_audmiso
))
4873 printk("audmiso-gpio get pin_mode fail!!!\n");
4879 printk("[mt_soc_codec_63xx] node NULL, can't Auddrv_getGPIO_info!!!\n");
4887 static struct platform_driver mtk_codec_6331_driver
=
4890 .name
= MT_SOC_CODEC_NAME
,
4891 .owner
= THIS_MODULE
,
4893 .of_match_table
= mt_soc_codec_63xx_of_ids
,
4896 .probe
= mtk_mt6331_codec_dev_probe
,
4897 .remove
= mtk_mt6331_codec_dev_remove
,
4901 static struct platform_device
*soc_mtk_codec6331_dev
;
4904 static int __init
mtk_mt6331_codec_init(void)
4906 printk("%s:\n", __func__
);
4908 //Auddrv_getGPIO_info();
4911 soc_mtk_codec6331_dev
= platform_device_alloc(MT_SOC_CODEC_NAME
, -1);
4912 if (!soc_mtk_codec6331_dev
)
4917 ret
= platform_device_add(soc_mtk_codec6331_dev
);
4920 platform_device_put(soc_mtk_codec6331_dev
);
4924 return platform_driver_register(&mtk_codec_6331_driver
);
4926 module_init(mtk_mt6331_codec_init
);
4928 static void __exit
mtk_mt6331_codec_exit(void)
4930 printk("%s:\n", __func__
);
4932 platform_driver_unregister(&mtk_codec_6331_driver
);
4935 module_exit(mtk_mt6331_codec_exit
);
4937 /* Module information */
4938 MODULE_DESCRIPTION("MTK codec driver");
4939 MODULE_LICENSE("GPL v2");