From cfbc7b2310678871486c4127c52be494803a908b Mon Sep 17 00:00:00 2001 From: Wen Xie Date: Mon, 11 Nov 2019 17:58:11 +0800 Subject: [PATCH] mfd: cs47l35: Update codec reg value. 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 Reviewed-on: https://gerrit.mot.com/1452347 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Zhengming Yao Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/mfd/madera-core.c | 2 +- sound/soc/codecs/madera.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c index cfdd6cae6a28..2410ffd1a8f5 100755 --- a/drivers/mfd/madera-core.c +++ b/drivers/mfd/madera-core.c @@ -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); diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 994621fe27c8..d497906eb485 100755 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -25,7 +25,7 @@ #include #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, -- 2.20.1