rk2928 codec: add soft reset.
authorZheng Yang <zhengyang@rock-chips.com>
Wed, 23 Jan 2013 10:15:37 +0000 (18:15 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Wed, 23 Jan 2013 10:15:37 +0000 (18:15 +0800)
sound/soc/codecs/rk2928_codec.c

index d450b320918dcf8dae1a17d57147e4f6b37feeee..6406c41661771309ef64dcd95ff81c44a32ed199 100755 (executable)
@@ -37,7 +37,7 @@
 #include <sound/soc.h>
 #include <sound/initval.h>
 #include <sound/tlv.h>
-
+#include <mach/cru.h>
 #include <mach/iomux.h>
 #include <mach/cpu.h>
 #include <linux/clk.h>
@@ -229,50 +229,49 @@ static int rk2928_audio_trigger(struct snd_pcm_substream *substream, int cmd,
                case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 //                             rk2928_write(codec, CODEC_REG_DAC_GAIN, v_GAIN_DAC(DAC_GAIN_3DB_P));
-                               if(!rk2928_data.hdmi_enable) {
-                                       data = rk2928_read(codec, CODEC_REG_POWER);
-                                       if(soc_is_rk2928g()){
-                                               if( (data & m_PD_ADC) == 0) {
-                                                       data &= ~m_PD_ADC;
-                                                       data |= v_PD_ADC(1);
-                                                       pd_adc = 1;
-                                               }
-                                               else
-                                                       pd_adc = 0;
-                                       }
-                                       else{
-                                               if( (data & m_PD_ADC_R) == 0) {
-                                                       data &= ~m_PD_ADC_R;
-                                                       data |= v_PD_ADC_R(1);
-                                                       pd_adc = 1;
-                                               }
-                                               else
-                                                       pd_adc = 0;
+                               data = rk2928_read(codec, CODEC_REG_POWER);
+                               if(soc_is_rk2928g()){
+                                       if( (data & m_PD_ADC) == 0) {
+                                               data &= ~m_PD_ADC;
+                                               data |= v_PD_ADC(1);
+                                               pd_adc = 1;
                                        }
-                                       if(pd_adc == 1) {
-                                               DBG("%s reg 0x%02x value 0x%02x", __FUNCTION__, CODEC_REG_POWER, data);
-                                               writel(data, rk2928_data.regbase + CODEC_REG_POWER*4);
-                                               udelay(100);                                            
+                                       else
+                                               pd_adc = 0;
+                               }
+                               else{
+                                       if( (data & m_PD_ADC_R) == 0) {
+                                               data &= ~m_PD_ADC_R;
+                                               data |= v_PD_ADC_R(1);
+                                               pd_adc = 1;
                                        }
-                                       rk2928_write(codec, CODEC_REG_ADC_SOURCE, 0x03);
+                                       else
+                                               pd_adc = 0;
+                               }
+                               if(pd_adc == 1) {
+                                       DBG("%s reg 0x%02x value 0x%02x", __FUNCTION__, CODEC_REG_POWER, data);
+                                       writel(data, rk2928_data.regbase + CODEC_REG_POWER*4);
+                                       udelay(100);                                            
+                               }
+                               rk2928_write(codec, CODEC_REG_ADC_SOURCE, 0x03);
+                               udelay(100);
+                               rk2928_write(codec, CODEC_REG_ADC_SOURCE, 0x00);
+                               
+                               if(pd_adc == 1) {
                                        udelay(100);
-                                       rk2928_write(codec, CODEC_REG_ADC_SOURCE, 0x00);
-                                       
-                                       if(pd_adc == 1) {
-                                               udelay(100);
-                                               data = rk2928_read(codec, CODEC_REG_POWER);
-                                               if( soc_is_rk2928g() ) {
-                                                       data &= ~m_PD_ADC;
-                                                       data |= v_PD_ADC(0);
-                                               }
-                                               else {
-                                                       data &= ~m_PD_ADC_R;
-                                                       data |= v_PD_ADC_R(0);
-                                               }
-                                               DBG("%s reg 0x%02x value 0x%02x", __FUNCTION__, CODEC_REG_POWER, data);
-                                               writel(data, rk2928_data.regbase + CODEC_REG_POWER*4);
+                                       data = rk2928_read(codec, CODEC_REG_POWER);
+                                       if( soc_is_rk2928g() ) {
+                                               data &= ~m_PD_ADC;
+                                               data |= v_PD_ADC(0);
+                                       }
+                                       else {
+                                               data &= ~m_PD_ADC_R;
+                                               data |= v_PD_ADC_R(0);
                                        }
-                                       
+                                       DBG("%s reg 0x%02x value 0x%02x", __FUNCTION__, CODEC_REG_POWER, data);
+                                       writel(data, rk2928_data.regbase + CODEC_REG_POWER*4);
+                               }
+                               if(!rk2928_data.hdmi_enable) {
                                        rk2928_write(codec, CODEC_REG_DAC_MUTE, v_MUTE_DAC(0));
                                        if(rk2928_data.spkctl != INVALID_GPIO && rk2928_data.headset_status == HP_OUT) {
                                                gpio_direction_output(rk2928_data.spkctl, GPIO_HIGH);
@@ -348,6 +347,14 @@ static int rk2928_set_bias_level(struct snd_soc_codec *codec,
        return 0;
 }
 
+static void rk2929_codec_reset(void)
+{
+       // Reset Codec
+       cru_set_soft_reset(SOFT_RST_ACODEC, true);
+       udelay(1000);
+       cru_set_soft_reset(SOFT_RST_ACODEC, false);
+}
+
 static int rk2928_probe(struct snd_soc_codec *codec)
 {
        struct platform_device *pdev = to_platform_device(codec->dev);