From 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 10 May 2024 07:44:59 +0000
Subject: [PATCH] gmac get mac form eeprom
---
kernel/sound/soc/codecs/rk817_codec.c | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/kernel/sound/soc/codecs/rk817_codec.c b/kernel/sound/soc/codecs/rk817_codec.c
index a334f76..8c767ce 100644
--- a/kernel/sound/soc/codecs/rk817_codec.c
+++ b/kernel/sound/soc/codecs/rk817_codec.c
@@ -286,10 +286,10 @@
{RK817_CODEC_AREF_RTCFG1, 0x40},
{RK817_CODEC_DDAC_POPD_DACST, 0x02},
/* APLL */
- {RK817_CODEC_APLL_CFG0, 0x04},
+ /* {RK817_CODEC_APLL_CFG0, 0x04}, */
{RK817_CODEC_APLL_CFG1, 0x58},
{RK817_CODEC_APLL_CFG2, 0x2d},
- {RK817_CODEC_APLL_CFG4, 0xa5},
+ /* {RK817_CODEC_APLL_CFG4, 0xa5}, */
{RK817_CODEC_APLL_CFG5, 0x00},
{RK817_CODEC_DI2S_RXCMD_TSD, 0x00},
@@ -324,10 +324,10 @@
{RK817_CODEC_AREF_RTCFG1, 0x40},
{RK817_CODEC_DADC_SR_ACL0, 0x02},
/* {RK817_CODEC_DTOP_DIGEN_CLKE, 0xff}, */
- {RK817_CODEC_APLL_CFG0, 0x04},
+ /* {RK817_CODEC_APLL_CFG0, 0x04}, */
{RK817_CODEC_APLL_CFG1, 0x58},
{RK817_CODEC_APLL_CFG2, 0x2d},
- {RK817_CODEC_APLL_CFG4, 0xa5},
+ /* {RK817_CODEC_APLL_CFG4, 0xa5}, */
{RK817_CODEC_APLL_CFG5, 0x00},
/*{RK817_CODEC_DI2S_RXCMD_TSD, 0x00},*/
@@ -378,12 +378,16 @@
playback_power_up_list[i].value);
}
- /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */
+ /* configure APLL CFG0/4 */
if (rk817->chip_ver <= 0x4) {
DBG("%s (%d): SMIC TudorAG and previous versions\n",
__func__, __LINE__);
snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c);
snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0x95);
+ } else {
+ DBG("%s: SMIC TudorAG version later\n", __func__);
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x04);
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0xa5);
}
snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
@@ -405,16 +409,20 @@
capture_power_up_list[i].value);
}
- /* Re-configure APLL CFG0/4 if (chip_ver <= 0x4) */
+ /* configure APLL CFG0/4 */
if (rk817->chip_ver <= 0x4) {
DBG("%s (%d): SMIC TudorAG and previous versions\n",
__func__, __LINE__);
snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x0c);
snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0x95);
+ } else {
+ DBG("%s: SMIC TudorAG version later\n", __func__);
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG0, 0x04);
+ snd_soc_component_write(component, RK817_CODEC_APLL_CFG4, 0xa5);
}
snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
- ADC_DIG_CLK_MASK, DAC_DIG_CLK_DIS);
+ ADC_DIG_CLK_MASK, ADC_DIG_CLK_DIS);
usleep_range(2000, 2500);
snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
ADC_DIG_CLK_MASK, ADC_DIG_CLK_EN);
@@ -1026,7 +1034,7 @@
return 0;
}
-static int rk817_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
+static int rk817_digital_mute_dac(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_component *component = dai->component;
struct rk817_codec_priv *rk817 = snd_soc_component_get_drvdata(component);
@@ -1048,7 +1056,11 @@
DAC_DIG_CLK_EN, DAC_DIG_CLK_DIS);
snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
DAC_DIG_CLK_EN, DAC_DIG_CLK_EN);
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
+ I2SRX_EN_MASK, I2SRX_DIS);
} else {
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
+ I2SRX_EN_MASK, I2SRX_EN);
snd_soc_component_update_bits(component,
RK817_CODEC_DDAC_MUTE_MIXCTL,
DACMT_ENABLE, DACMT_DISABLE);
@@ -1098,6 +1110,28 @@
return 0;
}
+static int rk817_digital_mute_adc(struct snd_soc_dai *dai, int mute, int stream)
+{
+ struct snd_soc_component *component = dai->component;
+
+ if (mute)
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
+ I2STX_EN_MASK, I2STX_DIS);
+ else
+ snd_soc_component_update_bits(component, RK817_CODEC_DTOP_DIGEN_CLKE,
+ I2STX_EN_MASK, I2STX_EN);
+
+ return 0;
+}
+
+static int rk817_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
+{
+ if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+ return rk817_digital_mute_dac(dai, mute, stream);
+ else
+ return rk817_digital_mute_adc(dai, mute, stream);
+}
+
#define RK817_PLAYBACK_RATES (SNDRV_PCM_RATE_8000 |\
SNDRV_PCM_RATE_16000 | \
SNDRV_PCM_RATE_32000 | \
@@ -1142,7 +1176,6 @@
.set_sysclk = rk817_set_dai_sysclk,
.mute_stream = rk817_digital_mute,
.shutdown = rk817_codec_shutdown,
- .no_capture_mute = 1,
};
static struct snd_soc_dai_driver rk817_dai[] = {
@@ -1230,9 +1263,9 @@
rk817->chip_ver = (chip_ver & 0x0f);
dev_info(component->dev, "%s: chip_name:0x%x, chip_ver:0x%x\n", __func__, chip_name, chip_ver);
+ /* always enable mclk, and will disable mclk in rk817_remove */
clk_prepare_enable(rk817->mclk);
rk817_reset(component);
- clk_disable_unprepare(rk817->mclk);
mutex_init(&rk817->clk_lock);
rk817->clk_capture = 0;
rk817->clk_playback = 0;
@@ -1257,6 +1290,7 @@
rk817_codec_power_down(component, RK817_CODEC_ALL);
snd_soc_component_exit_regmap(component);
mutex_destroy(&rk817->clk_lock);
+ clk_disable_unprepare(rk817->mclk);
mdelay(10);
}
--
Gitblit v1.6.2