hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/sound/soc/codecs/rk817_codec.c
....@@ -286,10 +286,10 @@
286286 {RK817_CODEC_AREF_RTCFG1, 0x40},
287287 {RK817_CODEC_DDAC_POPD_DACST, 0x02},
288288 /* APLL */
289
- {RK817_CODEC_APLL_CFG0, 0x04},
289
+ /* {RK817_CODEC_APLL_CFG0, 0x04}, */
290290 {RK817_CODEC_APLL_CFG1, 0x58},
291291 {RK817_CODEC_APLL_CFG2, 0x2d},
292
- {RK817_CODEC_APLL_CFG4, 0xa5},
292
+ /* {RK817_CODEC_APLL_CFG4, 0xa5}, */
293293 {RK817_CODEC_APLL_CFG5, 0x00},
294294
295295 {RK817_CODEC_DI2S_RXCMD_TSD, 0x00},
....@@ -324,10 +324,10 @@
324324 {RK817_CODEC_AREF_RTCFG1, 0x40},
325325 {RK817_CODEC_DADC_SR_ACL0, 0x02},
326326 /* {RK817_CODEC_DTOP_DIGEN_CLKE, 0xff}, */
327
- {RK817_CODEC_APLL_CFG0, 0x04},
327
+ /* {RK817_CODEC_APLL_CFG0, 0x04}, */
328328 {RK817_CODEC_APLL_CFG1, 0x58},
329329 {RK817_CODEC_APLL_CFG2, 0x2d},
330
- {RK817_CODEC_APLL_CFG4, 0xa5},
330
+ /* {RK817_CODEC_APLL_CFG4, 0xa5}, */
331331 {RK817_CODEC_APLL_CFG5, 0x00},
332332
333333 /*{RK817_CODEC_DI2S_RXCMD_TSD, 0x00},*/
....@@ -378,12 +378,16 @@
378378 playback_power_up_list[i].value);
379379 }
380380
381
- /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */
381
+ /* configure APLL CFG0/4 */
382382 if (rk817->chip_ver <= 0x4) {
383383 DBG("%s (%d): SMIC TudorAG and previous versions\n",
384384 __func__, __LINE__);
385385 snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c);
386386 snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0x95);
387
+ } else {
388
+ DBG("%s: SMIC TudorAG version later\n", __func__);
389
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x04);
390
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0xa5);
387391 }
388392
389393 snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
....@@ -405,16 +409,20 @@
405409 capture_power_up_list[i].value);
406410 }
407411
408
- /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */
412
+ /* configure APLL CFG0/4 */
409413 if (rk817->chip_ver <= 0x4) {
410414 DBG("%s (%d): SMIC TudorAG and previous versions\n",
411415 __func__, __LINE__);
412416 snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c);
413417 snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0x95);
418
+ } else {
419
+ DBG("%s: SMIC TudorAG version later\n", __func__);
420
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x04);
421
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0xa5);
414422 }
415423
416424 snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
417
- ADC_DIG_CLK_MASK, DAC_DIG_CLK_DIS);
425
+ ADC_DIG_CLK_MASK, ADC_DIG_CLK_DIS);
418426 usleep_range(2000, 2500);
419427 snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
420428 ADC_DIG_CLK_MASK, ADC_DIG_CLK_EN);
....@@ -1026,7 +1034,7 @@
10261034 return 0;
10271035 }
10281036
1029
-static int rk817_digital_mute(struct snd_soc_dai *dai, int mute)
1037
+static int rk817_digital_mute_dac(struct snd_soc_dai *dai, int mute, int stream)
10301038 {
10311039 struct snd_soc_component *component = dai->component;
10321040 struct rk817_codec_priv *rk817 = snd_soc_component_get_drvdata(component);
....@@ -1048,7 +1056,11 @@
10481056 DAC_DIG_CLK_EN, DAC_DIG_CLK_DIS);
10491057 snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
10501058 DAC_DIG_CLK_EN, DAC_DIG_CLK_EN);
1059
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
1060
+ I2SRX_EN_MASK, I2SRX_DIS);
10511061 } else {
1062
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
1063
+ I2SRX_EN_MASK, I2SRX_EN);
10521064 snd_soc_component_update_bits(component,
10531065 RK817_CODEC_DDAC_MUTE_MIXCTL,
10541066 DACMT_ENABLE, DACMT_DISABLE);
....@@ -1098,6 +1110,28 @@
10981110 return 0;
10991111 }
11001112
1113
+static int rk817_digital_mute_adc(struct snd_soc_dai *dai, int mute, int stream)
1114
+{
1115
+ struct snd_soc_component *component = dai->component;
1116
+
1117
+ if (mute)
1118
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
1119
+ I2STX_EN_MASK, I2STX_DIS);
1120
+ else
1121
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
1122
+ I2STX_EN_MASK, I2STX_EN);
1123
+
1124
+ return 0;
1125
+}
1126
+
1127
+static int rk817_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
1128
+{
1129
+ if (stream == SNDRV_PCM_STREAM_PLAYBACK)
1130
+ return rk817_digital_mute_dac(dai, mute, stream);
1131
+ else
1132
+ return rk817_digital_mute_adc(dai, mute, stream);
1133
+}
1134
+
11011135 #define RK817_PLAYBACK_RATES (SNDRV_PCM_RATE_8000 |\
11021136 SNDRV_PCM_RATE_16000 | \
11031137 SNDRV_PCM_RATE_32000 | \
....@@ -1140,7 +1174,7 @@
11401174 .hw_params = rk817_hw_params,
11411175 .set_fmt = rk817_set_dai_fmt,
11421176 .set_sysclk = rk817_set_dai_sysclk,
1143
- .digital_mute = rk817_digital_mute,
1177
+ .mute_stream = rk817_digital_mute,
11441178 .shutdown = rk817_codec_shutdown,
11451179 };
11461180
....@@ -1224,14 +1258,14 @@
12241258 rk817->playback_path = OFF;
12251259 rk817->capture_path = MIC_OFF;
12261260
1227
- chip_name = snd_soc_component_read32(component, RK817_PMIC_CHIP_NAME);
1228
- chip_ver = snd_soc_component_read32(component, RK817_PMIC_CHIP_VER);
1261
+ chip_name = snd_soc_component_read(component, RK817_PMIC_CHIP_NAME);
1262
+ chip_ver = snd_soc_component_read(component, RK817_PMIC_CHIP_VER);
12291263 rk817->chip_ver = (chip_ver & 0x0f);
12301264 dev_info(component->dev, "%s: chip_name:0x%x, chip_ver:0x%x\n", __func__, chip_name, chip_ver);
12311265
1266
+ /* always enable mclk, and will disable mclk in rk817_remove */
12321267 clk_prepare_enable(rk817->mclk);
12331268 rk817_reset(component);
1234
- clk_disable_unprepare(rk817->mclk);
12351269 mutex_init(&rk817->clk_lock);
12361270 rk817->clk_capture = 0;
12371271 rk817->clk_playback = 0;
....@@ -1256,6 +1290,7 @@
12561290 rk817_codec_power_down(component, RK817_CODEC_ALL);
12571291 snd_soc_component_exit_regmap(component);
12581292 mutex_destroy(&rk817->clk_lock);
1293
+ clk_disable_unprepare(rk817->mclk);
12591294 mdelay(10);
12601295
12611296 }