mfd: cs47l35: Update codec reg value.
authorWen Xie <xiewen3@motorola.com>
Sat, 2 Nov 2019 04:08:40 +0000 (12:08 +0800)
committerLu Lu <lulu2@lenovo.com>
Mon, 4 Nov 2019 09:53:26 +0000 (03:53 -0600)
cirrus vendor patch:
When detected the reg value in the cache is inconsistent with
the value in the hardware, update the hardware reg.

Change-Id: I8fb766819d5b05f8bbf9317471bf8f8fddf61227
Signed-off-by: Wen Xie <xiewen3@motorola.com>
Reviewed-on: https://gerrit.mot.com/1448151
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Zhengming Yao <yaozm1@mt.com>
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
(cherry picked from commit e0cd450d42a281814e06eed07584420d5f80555a)
Reviewed-on: https://gerrit.mot.com/1448422
Reviewed-by: Lu Lu <lulu2@mt.com>
SME-Granted: Lu Lu <lulu2@mt.com>
Submit-Approved: Lu Lu <lulu2@mt.com>

sound/soc/codecs/madera.c

index 994621fe27c8b7581c4ec844f3c677f4b1a716f5..d497906eb4854da9b5dabac3d65bbd699daa4d0a 100755 (executable)
@@ -25,7 +25,7 @@
 #include <dt-bindings/sound/madera.h>
 
 #include "madera.h"
-
+#define __FIX_SAMPLE_RATE_REWRITE_
 #define MADERA_AIF_BCLK_CTRL                   0x00
 #define MADERA_AIF_TX_PIN_CTRL                 0x01
 #define MADERA_AIF_RX_PIN_CTRL                 0x02
@@ -3299,6 +3299,10 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream,
        unsigned int cur, tar;
        bool change_rate_domain = false;
 
+#ifdef __FIX_SAMPLE_RATE_REWRITE_
+       int sr_status,sr_val_update;
+#endif
+
        for (i = 0; i < ARRAY_SIZE(madera_sr_vals); i++)
                if (madera_sr_vals[i] == params_rate(params))
                        break;
@@ -3367,6 +3371,36 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream,
                        snd_soc_update_bits(codec, base + MADERA_AIF_RATE_CTRL,
                                            MADERA_AIF1_RATE_MASK,
                                            0 << MADERA_AIF1_RATE_SHIFT);
+#ifdef __FIX_SAMPLE_RATE_REWRITE_
+               sr_status = snd_soc_read(codec, MADERA_SAMPLE_RATE_1_STATUS);
+               madera_aif_err(dai, "Sample Rate should be pair %d,%d\n",sr_status,sr_val);
+               if(sr_status != sr_val) {
+                       madera_aif_err(dai, "Illegal Sample Rate appear %d\n",sr_status);
+                       /*Then we need to rewrite the Sample Rate value and make it work, need different value*/
+                       sr_val_update=0x11;
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_1,
+                                   MADERA_SAMPLE_RATE_1_MASK, sr_val_update);
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2,
+                                   MADERA_SAMPLE_RATE_2_MASK, sr_val_update);
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_3,
+                                   MADERA_SAMPLE_RATE_3_MASK, sr_val_update);
+
+                       sr_val_update=sr_val;
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_1,
+                                   MADERA_SAMPLE_RATE_1_MASK, sr_val_update);
+
+                       sr_val_update=0x3;
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_3,
+                                   MADERA_SAMPLE_RATE_3_MASK, sr_val_update);
+
+                       sr_val_update=0x12;
+                       snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2,
+                                   MADERA_SAMPLE_RATE_2_MASK, sr_val_update);
+
+                       sr_status = snd_soc_read(codec, MADERA_SAMPLE_RATE_1_STATUS);
+                       madera_aif_err(dai, "Read Sample Rate status again %d\n",sr_status);
+               }
+#endif
                break;
        case MADERA_CLK_SYSCLK_2:
                snd_soc_update_bits(codec, MADERA_SAMPLE_RATE_2,