[PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree
From: "derek.fang" derek@realtek.com
The patch adds a new property to specify the mclk name which be used.
Signed-off-by: derek.fang derek@realtek.com
diff --git a/Documentation/devicetree/bindings/sound/rt5682.txt b/Documentation/devicetree/bindings/sound/rt5682.txt index cd8c53d8497e..bee935ef2974 100644 --- a/Documentation/devicetree/bindings/sound/rt5682.txt +++ b/Documentation/devicetree/bindings/sound/rt5682.txt @@ -46,6 +46,8 @@ Optional properties:
- realtek,dmic-clk-driving-high : Set the high driving of the DMIC clock out.
+- realtek,mclk-name : Specify the mclk name that codec uses as clock provider. + Pins on the device (for linking into audio routes) for RT5682:
* DMIC L1
From: "derek.fang" derek@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@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");
On Mon, Mar 22, 2021 at 08:47:05PM +0800, derek.fang@realtek.com wrote:
+- realtek,mclk-name : Specify the mclk name that codec uses as clock provider.
This is really non-idiomatic interface design for the device tree (or anything really) - the names for the clocks are defined at the device scope, it doesn't make sense to have a property like this.
participants (2)
-
derek.fang@realtek.com
-
Mark Brown