[Feature][ZXW-268][codec]Added codec re-initialization for power down and I2S default configuration adjustment
Only Configure: No
Affected branch: master
Affected module: codec
Is it affected on both ZXIC and MTK:only zxic
Self-test: Yes
Doc Update:No
Change-Id: I08292cac24da277ec95749b133379af48448f0e8
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
index 1bc3004..899ab9c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
@@ -1044,73 +1044,8 @@
static int es8311_resume(struct snd_soc_component *component)
{
- struct es8311_private *es8311 = snd_soc_component_get_drvdata(component);
-
printk("Enter into %s()\n", __func__);
- snd_soc_component_write(component, ES8311_GP_REG45, 0x00);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);
- snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x10);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);
- snd_soc_component_write(component, ES8311_SDPIN_REG09, 0x00);
- snd_soc_component_write(component, ES8311_SDPOUT_REG0A, 0x00);
- snd_soc_component_write(component, ES8311_SYSTEM_REG0B, 0x00);
- snd_soc_component_write(component, ES8311_SYSTEM_REG0C, 0x00);
-
- if (ES8311_AVDD == ES8311_1V8) {
- snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x61);
- snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x7B);
- } else {
- snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x03);
- snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x57);
- }
- if (es8311->mclk_src == ES8311_MCLK_PIN) {
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x3F);
- snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xBF);
- }
- if (es8311->mastermode == 1)
- snd_soc_component_write(component, ES8311_RESET_REG00, 0xC0);
- else
- snd_soc_component_write(component, ES8311_RESET_REG00, 0x80);
-
- usleep_range(1500, 3000);
- snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0x01);
-
- if (es8311->mclkinv == true) {
- snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01,
- 0x40, 0x40);
- } else {
- snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01,
- 0x40, 0x00);
- }
- if (es8311->sclkinv == true) {
- snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06,
- 0x20, 0x20);
- } else {
- snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06,
- 0x20, 0x00);
- }
- snd_soc_component_write(component, ES8311_SYSTEM_REG14, 0x1A);
- if (es8311->dmic_enable == true) {
- snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14,
- 0x40, 0x40);
- } else {
- snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14,
- 0x40, 0x00);
- }
- snd_soc_component_write(component, ES8311_SYSTEM_REG12, 0x00);
- snd_soc_component_write(component, ES8311_SYSTEM_REG13, 0x10);
- snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0x02);
- snd_soc_component_write(component, ES8311_SYSTEM_REG0F, 0x7F);
- snd_soc_component_write(component, ES8311_ADC_REG15, 0x40);
- snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);
- snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);
- snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
- snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);
- snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);
-
+ //yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment
return 0;
}
@@ -1251,19 +1186,9 @@
unsigned tmp;
printk("Enter into %s()\n", __func__);
-
-
- #if 1
- void __iomem *reg_base;
- reg_base = ioremap(0x13B000+0x94 ,4);
- tmp = ioread32(reg_base);
- tmp |= (1<<0)|(1<<2);
- iowrite32(tmp,reg_base);
-
-
- #endif
-
-
+
+ //yu.dong@20240416[T106BUG-551][codec] codec 8311 sleep power consumption does not go down
+
dev_info(dev, "%s:start!\n", __func__);
if(dev == NULL){
@@ -1357,6 +1282,91 @@
}
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
+static void es8311_reinit(struct snd_soc_component *component, struct es8311_private *es8311)
+{
+ pr_info("%s:begin!\n", __func__);
+
+ snd_soc_component_write(component, ES8311_GP_REG45, 0x00);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);
+ //snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);
+ snd_soc_component_write(component, ES8311_ADC_REG16, 0x21);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x10);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);
+ snd_soc_component_write(component, ES8311_SDPIN_REG09, 0x00);
+ snd_soc_component_write(component, ES8311_SDPOUT_REG0A, 0x00);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG0B, 0x00);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG0C, 0x00);
+
+ if (ES8311_AVDD == ES8311_1V8) {
+ snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x61);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x7B);
+ } else {
+ snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x03);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x57);
+ }
+
+ if (es8311->mclk_src == ES8311_MCLK_PIN) {
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x3F);
+ } else {
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xBF);
+ }
+
+ if (es8311->mastermode == 1) {
+ snd_soc_component_write(component, ES8311_RESET_REG00, 0xC0);
+ } else {
+ snd_soc_component_write(component, ES8311_RESET_REG00, 0x80);
+ }
+
+ usleep_range(1500, 3000);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0x01);
+
+ if (es8311->mclkinv == true) {
+ snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01, 0x40, 0x40);
+ } else {
+ snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01, 0x40, 0x00);
+ }
+
+ if (es8311->sclkinv == true) {
+ snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06, 0x20, 0x20);
+ } else {
+ snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06, 0x20, 0x00);
+ }
+
+ snd_soc_component_write(component, ES8311_SYSTEM_REG14, 0x1A);
+
+ if (es8311->dmic_enable == true) {
+ snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14, 0x40, 0x40);
+ } else {
+ snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14, 0x40, 0x00);
+ }
+
+ snd_soc_component_write(component, ES8311_SYSTEM_REG12, 0x00);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG13, 0x10);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0x02);
+ snd_soc_component_write(component, ES8311_SYSTEM_REG0F, 0x7F);
+ snd_soc_component_write(component, ES8311_ADC_REG15, 0x40);
+ snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);
+ snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);
+ snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
+ snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);
+ snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);
+
+ msleep(100);
+ es8311_set_bias_level(component, SND_SOC_BIAS_STANDBY);
+
+ pr_info("%s:end!\n", __func__);
+}
+
+extern int zx29_i2s_config_sleep_pin(void);
+extern int zx29_i2s_config_default_pin(void);
+
static int component_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
@@ -1373,6 +1383,12 @@
}
}
+ ret = zx29_i2s_config_default_pin();
+ if(ret < 0) {
+ pr_err("%s select state failure %d !! \n", __func__, ret);
+ }
+ es8311_reinit(component, info);
+
pr_info("%s:clk en end!\n",__func__);
return ret;
@@ -1396,13 +1412,19 @@
}
pr_info("%s:clk dis end!\n",__func__);
-
+
+ ret = zx29_i2s_config_sleep_pin();
+ if(ret < 0) {
+ pr_err("%s select state failure %d !! \n", __func__, ret);
+ }
+
return ret;
}
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment end
static const struct snd_soc_component_driver soc_component_dev_es8311 = {
.probe = es8311_probe,
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
index e059a8d..4e56af4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
@@ -851,8 +851,8 @@
info->s = s;
info->s_sleep = s_sleep;
}
-
- ret = pinctrl_select_state(p, s);
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
+ ret = pinctrl_select_state(p, s_sleep);
if (ret < 0) {
devm_pinctrl_put(p);
dev_err(dev, " select state failure!!\n");
@@ -862,6 +862,38 @@
}
+int zx29_i2s_config_default_pin(void)
+{
+ struct zx29_board_data *info = s_board;
+ int ret;
+
+ if (!info || !info->p || !info->s)
+ return -ENODEV;
+
+ ret = pinctrl_select_state(info->p, info->s);
+ if (ret < 0) {
+ pr_err(" %s select state failure %d!!\n", __func__, ret);
+ }
+
+ return ret;
+}
+
+int zx29_i2s_config_sleep_pin(void)
+{
+ struct zx29_board_data *info = s_board;
+ int ret;
+
+ if (!info || !info->p || !info->s_sleep)
+ return -ENODEV;
+
+ ret = pinctrl_select_state(info->p, info->s_sleep);
+ if (ret < 0) {
+ pr_err(" %s select state failure %d!!\n", __func__, ret);
+ }
+
+ return ret;
+}
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment end
static int zx29_audio_probe(struct platform_device *pdev)
{