| .. | .. |
|---|
| 286 | 286 | {RK817_CODEC_AREF_RTCFG1, 0x40}, |
|---|
| 287 | 287 | {RK817_CODEC_DDAC_POPD_DACST, 0x02}, |
|---|
| 288 | 288 | /* APLL */ |
|---|
| 289 | | - {RK817_CODEC_APLL_CFG0, 0x04}, |
|---|
| 289 | + /* {RK817_CODEC_APLL_CFG0, 0x04}, */ |
|---|
| 290 | 290 | {RK817_CODEC_APLL_CFG1, 0x58}, |
|---|
| 291 | 291 | {RK817_CODEC_APLL_CFG2, 0x2d}, |
|---|
| 292 | | - {RK817_CODEC_APLL_CFG4, 0xa5}, |
|---|
| 292 | + /* {RK817_CODEC_APLL_CFG4, 0xa5}, */ |
|---|
| 293 | 293 | {RK817_CODEC_APLL_CFG5, 0x00}, |
|---|
| 294 | 294 | |
|---|
| 295 | 295 | {RK817_CODEC_DI2S_RXCMD_TSD, 0x00}, |
|---|
| .. | .. |
|---|
| 324 | 324 | {RK817_CODEC_AREF_RTCFG1, 0x40}, |
|---|
| 325 | 325 | {RK817_CODEC_DADC_SR_ACL0, 0x02}, |
|---|
| 326 | 326 | /* {RK817_CODEC_DTOP_DIGEN_CLKE, 0xff}, */ |
|---|
| 327 | | - {RK817_CODEC_APLL_CFG0, 0x04}, |
|---|
| 327 | + /* {RK817_CODEC_APLL_CFG0, 0x04}, */ |
|---|
| 328 | 328 | {RK817_CODEC_APLL_CFG1, 0x58}, |
|---|
| 329 | 329 | {RK817_CODEC_APLL_CFG2, 0x2d}, |
|---|
| 330 | | - {RK817_CODEC_APLL_CFG4, 0xa5}, |
|---|
| 330 | + /* {RK817_CODEC_APLL_CFG4, 0xa5}, */ |
|---|
| 331 | 331 | {RK817_CODEC_APLL_CFG5, 0x00}, |
|---|
| 332 | 332 | |
|---|
| 333 | 333 | /*{RK817_CODEC_DI2S_RXCMD_TSD, 0x00},*/ |
|---|
| .. | .. |
|---|
| 378 | 378 | playback_power_up_list[i].value); |
|---|
| 379 | 379 | } |
|---|
| 380 | 380 | |
|---|
| 381 | | - /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */ |
|---|
| 381 | + /* configure APLL CFG0/4 */ |
|---|
| 382 | 382 | if (rk817->chip_ver <= 0x4) { |
|---|
| 383 | 383 | DBG("%s (%d): SMIC TudorAG and previous versions\n", |
|---|
| 384 | 384 | __func__, __LINE__); |
|---|
| 385 | 385 | snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c); |
|---|
| 386 | 386 | 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); |
|---|
| 387 | 391 | } |
|---|
| 388 | 392 | |
|---|
| 389 | 393 | snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE, |
|---|
| .. | .. |
|---|
| 405 | 409 | capture_power_up_list[i].value); |
|---|
| 406 | 410 | } |
|---|
| 407 | 411 | |
|---|
| 408 | | - /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */ |
|---|
| 412 | + /* configure APLL CFG0/4 */ |
|---|
| 409 | 413 | if (rk817->chip_ver <= 0x4) { |
|---|
| 410 | 414 | DBG("%s (%d): SMIC TudorAG and previous versions\n", |
|---|
| 411 | 415 | __func__, __LINE__); |
|---|
| 412 | 416 | snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c); |
|---|
| 413 | 417 | 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); |
|---|
| 414 | 422 | } |
|---|
| 415 | 423 | |
|---|
| 416 | 424 | 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); |
|---|
| 418 | 426 | usleep_range(2000, 2500); |
|---|
| 419 | 427 | snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE, |
|---|
| 420 | 428 | ADC_DIG_CLK_MASK, ADC_DIG_CLK_EN); |
|---|
| .. | .. |
|---|
| 1026 | 1034 | return 0; |
|---|
| 1027 | 1035 | } |
|---|
| 1028 | 1036 | |
|---|
| 1029 | | -static int rk817_digital_mute(struct snd_soc_dai *dai, int mute, int stream) |
|---|
| 1037 | +static int rk817_digital_mute_dac(struct snd_soc_dai *dai, int mute, int stream) |
|---|
| 1030 | 1038 | { |
|---|
| 1031 | 1039 | struct snd_soc_component *component = dai->component; |
|---|
| 1032 | 1040 | struct rk817_codec_priv *rk817 = snd_soc_component_get_drvdata(component); |
|---|
| .. | .. |
|---|
| 1048 | 1056 | DAC_DIG_CLK_EN, DAC_DIG_CLK_DIS); |
|---|
| 1049 | 1057 | snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE, |
|---|
| 1050 | 1058 | 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); |
|---|
| 1051 | 1061 | } else { |
|---|
| 1062 | + snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE, |
|---|
| 1063 | + I2SRX_EN_MASK, I2SRX_EN); |
|---|
| 1052 | 1064 | snd_soc_component_update_bits(component, |
|---|
| 1053 | 1065 | RK817_CODEC_DDAC_MUTE_MIXCTL, |
|---|
| 1054 | 1066 | DACMT_ENABLE, DACMT_DISABLE); |
|---|
| .. | .. |
|---|
| 1098 | 1110 | return 0; |
|---|
| 1099 | 1111 | } |
|---|
| 1100 | 1112 | |
|---|
| 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 | + |
|---|
| 1101 | 1135 | #define RK817_PLAYBACK_RATES (SNDRV_PCM_RATE_8000 |\ |
|---|
| 1102 | 1136 | SNDRV_PCM_RATE_16000 | \ |
|---|
| 1103 | 1137 | SNDRV_PCM_RATE_32000 | \ |
|---|
| .. | .. |
|---|
| 1142 | 1176 | .set_sysclk = rk817_set_dai_sysclk, |
|---|
| 1143 | 1177 | .mute_stream = rk817_digital_mute, |
|---|
| 1144 | 1178 | .shutdown = rk817_codec_shutdown, |
|---|
| 1145 | | - .no_capture_mute = 1, |
|---|
| 1146 | 1179 | }; |
|---|
| 1147 | 1180 | |
|---|
| 1148 | 1181 | static struct snd_soc_dai_driver rk817_dai[] = { |
|---|
| .. | .. |
|---|
| 1230 | 1263 | rk817->chip_ver = (chip_ver & 0x0f); |
|---|
| 1231 | 1264 | dev_info(component->dev, "%s: chip_name:0x%x, chip_ver:0x%x\n", __func__, chip_name, chip_ver); |
|---|
| 1232 | 1265 | |
|---|
| 1266 | + /* always enable mclk, and will disable mclk in rk817_remove */ |
|---|
| 1233 | 1267 | clk_prepare_enable(rk817->mclk); |
|---|
| 1234 | 1268 | rk817_reset(component); |
|---|
| 1235 | | - clk_disable_unprepare(rk817->mclk); |
|---|
| 1236 | 1269 | mutex_init(&rk817->clk_lock); |
|---|
| 1237 | 1270 | rk817->clk_capture = 0; |
|---|
| 1238 | 1271 | rk817->clk_playback = 0; |
|---|
| .. | .. |
|---|
| 1257 | 1290 | rk817_codec_power_down(component, RK817_CODEC_ALL); |
|---|
| 1258 | 1291 | snd_soc_component_exit_regmap(component); |
|---|
| 1259 | 1292 | mutex_destroy(&rk817->clk_lock); |
|---|
| 1293 | + clk_disable_unprepare(rk817->mclk); |
|---|
| 1260 | 1294 | mdelay(10); |
|---|
| 1261 | 1295 | |
|---|
| 1262 | 1296 | } |
|---|