alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree
@ 2021-03-22 12:47 derek.fang
  2021-03-22 12:47 ` [PATCH 2/2] ASoC: rt5682: Read property to get mclk control derek.fang
  2021-03-22 13:01 ` [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: derek.fang @ 2021-03-22 12:47 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: oder_chiou, jack.yu, alsa-devel, lars, derek.fang, derek.fang,
	shumingf, flove

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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ASoC: rt5682: Read property to get mclk control
  2021-03-22 12:47 [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree derek.fang
@ 2021-03-22 12:47 ` derek.fang
  2021-03-22 13:01 ` [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: derek.fang @ 2021-03-22 12:47 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: oder_chiou, jack.yu, alsa-devel, lars, derek.fang, derek.fang,
	shumingf, flove

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");
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree
  2021-03-22 12:47 [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree derek.fang
  2021-03-22 12:47 ` [PATCH 2/2] ASoC: rt5682: Read property to get mclk control derek.fang
@ 2021-03-22 13:01 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-03-22 13:01 UTC (permalink / raw)
  To: derek.fang
  Cc: oder_chiou, jack.yu, alsa-devel, lars, lgirdwood, derek.fang,
	shumingf, flove

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-22 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-22 12:47 [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree derek.fang
2021-03-22 12:47 ` [PATCH 2/2] ASoC: rt5682: Read property to get mclk control derek.fang
2021-03-22 13:01 ` [PATCH 1/2] ASoC: rt5682: Add a mclk name property to the device tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).