mfd: cs47l35: Update codec reg value.
authorWen Xie <xiewen3@motorola.com>
Mon, 11 Nov 2019 09:58:11 +0000 (17:58 +0800)
committerWen Xie <xiewen3@motorola.com>
Tue, 12 Nov 2019 02:25:05 +0000 (20:25 -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: I0aea0c59665f470a8625601ac3abbbd915f8dbee
Signed-off-by: Wen Xie <xiewen3@motorola.com>
Reviewed-on: https://gerrit.mot.com/1452347
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

drivers/mfd/madera-core.c
sound/soc/codecs/madera.c

index cfdd6cae6a287c1d582db57288f78187d7ebe32f..2410ffd1a8f50f9f4a8a1b3e00ef2004b149b9fc 100755 (executable)
@@ -275,7 +275,7 @@ static int madera_runtime_resume(struct device *dev)
        struct madera *madera = dev_get_drvdata(dev);
        int ret;
 
-       dev_dbg(dev, "Leaving sleep mode\n");
+       dev_err(dev, "Leaving sleep mode\n");
 
        madera_enable_hard_reset(madera);
 
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,