[PATCH 2/2] ASoC: rt5682: Read property to get mclk control
derek.fang at realtek.com
derek.fang at realtek.com
Mon Mar 22 13:47:06 CET 2021
From: "derek.fang" <derek at realtek.com>
The systems can use ACPI DSDT to pass on the mclk to rt5682.
Enable/Disable of the mclk is already handled in the codec so
platform drivers don't have to explicitly do handling of mclk.
Signed-off-by: derek.fang <derek at realtek.com>
diff --git a/include/sound/rt5682.h b/include/sound/rt5682.h
index 3900a07e3935..8b5288176bc4 100644
--- a/include/sound/rt5682.h
+++ b/include/sound/rt5682.h
@@ -43,6 +43,7 @@ struct rt5682_platform_data {
bool dmic_clk_driving_high;
const char *dai_clk_names[RT5682_DAI_NUM_CLKS];
+ const char *mclk_name;
};
#endif
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 0e2a10ed11da..263f71dfd060 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2875,7 +2875,8 @@ static int rt5682_probe(struct snd_soc_component *component)
} else {
#ifdef CONFIG_COMMON_CLK
/* Check if MCLK provided */
- rt5682->mclk = devm_clk_get(component->dev, "mclk");
+ if (rt5682->pdata.mclk_name)
+ rt5682->mclk = devm_clk_get(NULL, rt5682->pdata.mclk_name);
if (IS_ERR(rt5682->mclk)) {
if (PTR_ERR(rt5682->mclk) != -ENOENT) {
ret = PTR_ERR(rt5682->mclk);
@@ -2905,6 +2906,11 @@ static void rt5682_remove(struct snd_soc_component *component)
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
rt5682_reset(rt5682);
+
+#ifdef CONFIG_COMMON_CLK
+ if (rt5682->pdata.mclk_name)
+ devm_clk_put(rt5682->mclk);
+#endif
}
#ifdef CONFIG_PM
@@ -3002,6 +3008,9 @@ int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
rt5682->pdata.dai_clk_names[RT5682_DAI_WCLK_IDX],
rt5682->pdata.dai_clk_names[RT5682_DAI_BCLK_IDX]);
+ device_property_read_string(dev, "realtek,mclk-name",
+ &rt5682->pdata.mclk_name);
+
rt5682->pdata.dmic_clk_driving_high = device_property_read_bool(dev,
"realtek,dmic-clk-driving-high");
--
2.17.1
More information about the Alsa-devel
mailing list